Skip to content

Instantly share code, notes, and snippets.

@mosfet1kg
Created July 31, 2015 16:02
Show Gist options
  • Save mosfet1kg/009cf23433f8582b153b to your computer and use it in GitHub Desktop.
Save mosfet1kg/009cf23433f8582b153b to your computer and use it in GitHub Desktop.
async_waterfall_in_parallel
var async = require('async');
var products = ['a', 'b', 'c', 'd', 'e'];
var funcs = [];
products.forEach(function(item){
funcs.push(
function(callback){
async.waterfall([
function(callback){
setTimeout(function(){
console.log(item);
callback(null, item)
},500);
},
function(arg, callback){
console.log(arg);
callback(null)
},
function(callback){
console.log(item);
callback(null);
}
], function(err, result){
callback(null);
});
}
)
});
async.waterfall(funcs,
function(err, results) {
console.log(arguments);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment