{"action":"created","issue":{"url":"https://api.github.com/repos/marcuswestin/store.js/issues/224","repository_url":"https://api.github.com/repos/marcuswestin/store.js","labels_url":"https://api.github.com/repos/marcuswestin/store.js/issues/224/labels{/name}","comments_url":"https://api.github.com/repos/marcuswestin/store.js/issues/224/comments","events_url":"https://api.github.com/repos/marcuswestin/store.js/issues/224/events","html_url":"https://github.com/marcuswestin/store.js/issues/224","id":214675886,"node_id":"MDU6SXNzdWUyMTQ2NzU4ODY=","number":224,"title":"forEach not working as expected","user":{"login":"dperezrada","id":369653,"node_id":"MDQ6VXNlcjM2OTY1Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/369653?v=4","gravatar_id":"","url":"https://api.github.com/users/dperezrada","html_url":"https://github.com/dperezrada","followers_url":"https://api.github.com/users/dperezrada/followers","following_url":"https://api.github.com/users/dperezrada/following{/other_user}","gists_url":"https://api.github.com/users/dperezrada/gists{/gist_id}","starred_url":"https://api.github.com/users/dperezrada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dperezrada/subscriptions","organizations_url":"https://api.github.com/users/dperezrada/orgs","repos_url":"https://api.github.com/users/dperezrada/repos","events_url":"https://api.github.com/users/dperezrada/events{/privacy}","received_events_url":"https://api.github.com/users/dperezrada/received_events","type":"User","site_admin":false},"labels":[{"id":549941466,"node_id":"MDU6TGFiZWw1NDk5NDE0NjY=","url":"https://api.github.com/repos/marcuswestin/store.js/labels/Bug","name":"Bug","color":"b60205","default":false}],"state":"open","locked":false,"assignee":{"login":"marcuswestin","id":131967,"node_id":"MDQ6VXNlcjEzMTk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/131967?v=4","gravatar_id":"","url":"https://api.github.com/users/marcuswestin","html_url":"https://github.com/marcuswestin","followers_url":"https://api.github.com/users/marcuswestin/followers","following_url":"https://api.github.com/users/marcuswestin/following{/other_user}","gists_url":"https://api.github.com/users/marcuswestin/gists{/gist_id}","starred_url":"https://api.github.com/users/marcuswestin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcuswestin/subscriptions","organizations_url":"https://api.github.com/users/marcuswestin/orgs","repos_url":"https://api.github.com/users/marcuswestin/repos","events_url":"https://api.github.com/users/marcuswestin/events{/privacy}","received_events_url":"https://api.github.com/users/marcuswestin/received_events","type":"User","site_admin":false},"assignees":[{"login":"marcuswestin","id":131967,"node_id":"MDQ6VXNlcjEzMTk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/131967?v=4","gravatar_id":"","url":"https://api.github.com/users/marcuswestin","html_url":"https://github.com/marcuswestin","followers_url":"https://api.github.com/users/marcuswestin/followers","following_url":"https://api.github.com/users/marcuswestin/following{/other_user}","gists_url":"https://api.github.com/users/marcuswestin/gists{/gist_id}","starred_url":"https://api.github.com/users/marcuswestin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcuswestin/subscriptions","organizations_url":"https://api.github.com/users/marcuswestin/orgs","repos_url":"https://api.github.com/users/marcuswestin/repos","events_url":"https://api.github.com/users/marcuswestin/events{/privacy}","received_events_url":"https://api.github.com/users/marcuswestin/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2017-03-16T11:36:39Z","updated_at":"2018-10-11T14:10:29Z","closed_at":null,"author_association":"NONE","body":"When deleting or adding elements inside a foreach, or during the foreach. Is causing change in the length of the storage, \r\n```js\r\nfor (var index = 0; index < 100; index++) {\r\n\tstore.set('k_'+index, index)\r\n}\r\nvar found_elements = [];\r\nstore.forEach(function(key, val) {\r\n\tstore.remove(key);\r\n\tfound_elements.push(key);\r\n});\r\nconsole.log(\"Found elements:\", found_elements.length);\r\n//The output is: Found elements: 50\r\n```\r\nAfter this code runs, it leaves 50 elements (tested with localstorage). \r\n\r\nSeen the implementation of localstorage, it's clear that this problem has to happen:\r\n```js\r\nfor (var i = localStorage().length - 1; i >= 0; i--) {\r\n\tvar key = localStorage().key(i)\r\n\tfn(read(key), key)\r\n}\r\n```\r\n\r\nMaybe it could be solve with this, but not sure if there are other reasons to not do this.\r\n```js\r\nvar curentState = localStorage();\r\nfor (var i = curentState.length - 1; i >= 0; i--) {\r\n\tvar key = curentState.key(i)\r\n\tfn(read(key), key)\r\n}\r\n```\r\nThanks in advance, this is a great library."},"comment":{"url":"https://api.github.com/repos/marcuswestin/store.js/issues/comments/428970177","html_url":"https://github.com/marcuswestin/store.js/issues/224#issuecomment-428970177","issue_url":"https://api.github.com/repos/marcuswestin/store.js/issues/224","id":428970177,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODk3MDE3Nw==","user":{"login":"dperezrada","id":369653,"node_id":"MDQ6VXNlcjM2OTY1Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/369653?v=4","gravatar_id":"","url":"https://api.github.com/users/dperezrada","html_url":"https://github.com/dperezrada","followers_url":"https://api.github.com/users/dperezrada/followers","following_url":"https://api.github.com/users/dperezrada/following{/other_user}","gists_url":"https://api.github.com/users/dperezrada/gists{/gist_id}","starred_url":"https://api.github.com/users/dperezrada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dperezrada/subscriptions","organizations_url":"https://api.github.com/users/dperezrada/orgs","repos_url":"https://api.github.com/users/dperezrada/repos","events_url":"https://api.github.com/users/dperezrada/events{/privacy}","received_events_url":"https://api.github.com/users/dperezrada/received_events","type":"User","site_admin":false},"created_at":"2018-10-11T14:10:29Z","updated_at":"2018-10-11T14:10:29Z","author_association":"NONE","body":"I wrote a test to check if this was a problem in the current version. And I did a pull request with the test https://github.com/marcuswestin/store.js/pull/292 \r\nIt seems that current version using each, doesn't have the problem when removing elements anymore.\r\n\r\n\r\n"}}
{"actor":{"display_login":"dperezrada"}}