Created
February 10, 2014 18:58
-
-
Save getify/8921982 to your computer and use it in GitHub Desktop.
using asynquence.map() for an async forEach()
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
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