Created
January 10, 2017 19:45
-
-
Save rodrigogs/47e73169a8ec989d294bedfe6acb4402 to your computer and use it in GitHub Desktop.
Processing list using promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require('bluebird'); | |
const list = [1, 2, 3, 4]; | |
function multiplyBy2(x) { | |
return Promise.resolve(x * 2); | |
} | |
Promise.all(list.map(multiplyBy2)) | |
.then(console.log); | |
// Result will be 2, 4, 6, 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment