Created
October 17, 2018 15:27
-
-
Save caolan/1afc42132f2b26e2252b98c56cb3deb5 to your computer and use it in GitHub Desktop.
async.eachLimit equivalent for Promises (via Highland)
This file contains hidden or 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
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