Skip to content

Instantly share code, notes, and snippets.

@bekzod
Created October 11, 2014 09:49
Show Gist options
  • Select an option

  • Save bekzod/f29ef8ce23cf5e0d9cf8 to your computer and use it in GitHub Desktop.

Select an option

Save bekzod/f29ef8ce23cf5e0d9cf8 to your computer and use it in GitHub Desktop.
var async = require('async');
function someFunc(i, callback){
function cbWrapper(){
callback(null, i);
}
i % 2 == 0 ? cbWrapper() : setTimeout(cbWrapper, 100);
}
var jobs = [];
for (var t = 0; t < 10; t++) {
jobs.push( someFunc.bind(someFunc, t ) );
}
async.parallel([
function(callback){
async.parallel(jobs,callback);
}
], function(err,res){
console.log(res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment