Last active
August 29, 2015 13:56
-
-
Save leonguyen/9304841 to your computer and use it in GitHub Desktop.
async.series
This file contains hidden or 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
| 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