Skip to content

Instantly share code, notes, and snippets.

@leonguyen
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save leonguyen/9304841 to your computer and use it in GitHub Desktop.

Select an option

Save leonguyen/9304841 to your computer and use it in GitHub Desktop.
async.series
async.series([
function(callback){
// do some stuff ...
callback(null, 'one');
},
function(callback){
// do some more stuff ...
callback(null, 'two');
},
],
// optional callback
function(err, results){
// results is now equal to ['one', 'two']
});//async.series
// an example using an object instead of an array
async.series({
one: function(callback){
setTimeout(function(){
callback(null, 1);
}, 200);
},
two: function(callback){
setTimeout(function(){
callback(null, 2);
}, 100);
},
},
function(err, results) {
// results is now equals to: {one: 1, two: 2}
});//async.series
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment