Created
July 31, 2015 16:02
-
-
Save mosfet1kg/009cf23433f8582b153b to your computer and use it in GitHub Desktop.
async_waterfall_in_parallel
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
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