{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/821","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/821/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/821/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/821/events","html_url":"https://github.com/petkaantonov/bluebird/issues/821","id":113683097,"number":821,"title":"New .each behaviour and implicit returns","user":{"login":"joepie91","id":1663259,"avatar_url":"https://avatars.githubusercontent.com/u/1663259?v=3","gravatar_id":"","url":"https://api.github.com/users/joepie91","html_url":"https://github.com/joepie91","followers_url":"https://api.github.com/users/joepie91/followers","following_url":"https://api.github.com/users/joepie91/following{/other_user}","gists_url":"https://api.github.com/users/joepie91/gists{/gist_id}","starred_url":"https://api.github.com/users/joepie91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joepie91/subscriptions","organizations_url":"https://api.github.com/users/joepie91/orgs","repos_url":"https://api.github.com/users/joepie91/repos","events_url":"https://api.github.com/users/joepie91/events{/privacy}","received_events_url":"https://api.github.com/users/joepie91/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":35,"created_at":"2015-10-27T20:34:17Z","updated_at":"2015-10-28T01:21:05Z","closed_at":null,"body":"In 3.0, the behaviour of `each` was changed to behave like a sequential `map`. I feel this was a mistake. The following code:\r\n\r\n```javascript\r\nPromise.each([\"a\", \"b\", \"c\"], item => console.log(item) ).then(result => console.log(final) )\r\n```\r\n\r\n... will result in `final` holding `[undefined, undefined, undefined]`, which is not what one would expect for an iterator that is meant to be used for side-effects.\r\n\r\n```javascript\r\n> Promise.each([\"a\", \"b\", \"c\"], item => console.log(item) ).then(result => console.log(result) )\r\nPromise {\r\n  _bitField: 0,\r\n  _fulfillmentHandler0: undefined,\r\n  _rejectionHandler0: undefined,\r\n  _promise0: undefined,\r\n  _receiver0: undefined }\r\n> a\r\nb\r\nc\r\n[ undefined, undefined, undefined ]\r\n```\r\n\r\nThis problem occurs not only with ES6 arrow functions, but also with implicit returns in other languages like CoffeeScript. I'd consider this a major footgun, as virtually no side-effect-y methods will return the original value.\r\n\r\nShould this 'sequential map' behaviour not simply have moved to a new, separate method, without affecting the behaviour of `each`?"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/151690200","html_url":"https://github.com/petkaantonov/bluebird/issues/821#issuecomment-151690200","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/821","id":151690200,"user":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T01:21:05Z","updated_at":"2015-10-28T01:21:05Z","body":"@bergus I couldn't agree more but this whole thread seems to be opposed to that. Also, deprecation is not even a breaking change while changing .each back to 2.x would be, so that's all good reasons for deprecating it.\r\n"}}