Skip to content

Instantly share code, notes, and snippets.

@dineshsprabu
Created January 19, 2016 05:24
Show Gist options
  • Save dineshsprabu/3c27c80b0ec8563bf497 to your computer and use it in GitHub Desktop.
Save dineshsprabu/3c27c80b0ec8563bf497 to your computer and use it in GitHub Desktop.
NodeJS Async Series Example
var async = require("async");
//series calls the final callback function on every successful execution of the function in the list.
async.series([
function(callback) {
setTimeout(function() {
console.log("Task 1");
callback(null, 1);
}, 300);
},
function(callback) {
setTimeout(function() {
console.log("Task 2");
callback(null, 2);
}, 200);
},
function(callback) {
setTimeout(function() {
console.log("Task 3");
callback(null, 3);
}, 100);
}
], function(error, results) {
console.log(results);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment