Skip to content

Instantly share code, notes, and snippets.

@getify
Created February 10, 2014 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/8921982 to your computer and use it in GitHub Desktop.
Save getify/8921982 to your computer and use it in GitHub Desktop.
using asynquence.map() for an async forEach()
function handleItem(val,cb) {
setTimeout( function(){
console.log( val );
cb();
}, 100 );
}
ASQ()
.map(
[1,2,3,4,5]
handleItem
);
// map() used in this way *would* return/pass along a
// value-message of an array of 5 undefined values
// since you didn't map the orig items to anything
// when you called `cb()`.
//
// BUT, you can just ignore that resultant array in the
// next step of your sequence, and it functioned
// exactly like a forEach would have. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment