Skip to content

Instantly share code, notes, and snippets.

@shaikh-shahid
Created April 6, 2016 12:17
Show Gist options
  • Save shaikh-shahid/7011d3983483a291ed03fd8b328cadbc to your computer and use it in GitHub Desktop.
Save shaikh-shahid/7011d3983483a291ed03fd8b328cadbc to your computer and use it in GitHub Desktop.
var async = require('async');
async.forEach(someData,function(singleData,callback){
async.series();
//OR
async.paralle();
//OR
async.waterfall();
},function(err,data) {
// final callback
});
// going more deep.
async.forEach(someData,function(singleData,callback){
async.waterfall([
function(callback) {
async.forEachLimit(somedata,100,function(singleData,callback){
// You can use more combo here too.
callback(null);
},function(err) {
// final callback
// Now call the callback of waterfall.
callback(null,"No error");
});
}
],function(err,data) {
// callback of top async.forEach()
callback(null);
});
},function(err) {
// final callback
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment