Skip to content

Instantly share code, notes, and snippets.

@rodrigogs
Created January 10, 2017 19:45
Show Gist options
  • Save rodrigogs/47e73169a8ec989d294bedfe6acb4402 to your computer and use it in GitHub Desktop.
Save rodrigogs/47e73169a8ec989d294bedfe6acb4402 to your computer and use it in GitHub Desktop.
Processing list using promises
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