Skip to content

Instantly share code, notes, and snippets.

@caolan
Created October 17, 2018 15:27
Show Gist options
  • Save caolan/1afc42132f2b26e2252b98c56cb3deb5 to your computer and use it in GitHub Desktop.
Save caolan/1afc42132f2b26e2252b98c56cb3deb5 to your computer and use it in GitHub Desktop.
async.eachLimit equivalent for Promises (via Highland)
var Highland = require('highland');
function addOne(x) {
return new Promise((resolve, reject) => resolve(x + 1));
}
var limit = 10;
Highland([1,2,3,4,5])
.map((x) => Highland(addOne(x)))
.parallel(limit)
.toArray((result) => console.log(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment