The forEachAsync module of FuturesJS (Ender.JS and Node.JS)
$ npm install forEachAsync
Another reincarnation of sequence that makes sense for the use case of arrays.
Example:
var forEachAsync = require('forEachAsync')
, count = 0
, timers = [
101,
502,
203,
604,
105
];
function hello(next, time) {
this[count] = time;
if (count >= 4) {
next(forEachAsync.BREAK);
}
console.log(count += 1, time);
setTimeout(next, time);
}
function goodbye() {
console.log("All Done", this);
}
forEachAsync(timers, hello, {}).then(goodbye);
Warning: Poorly written code may have really strange errors when Array.prototype is extended.
If you run into such problems please contact the author of the code (I'm also willing to help if they are unavailable).
Libraries such as jQuery or MooTools will accept bug reports for such failures.
© 2010 - cnpmjs.org x YWFE | Home | YWFE