The async.parallel
executes all functions in parallel. If any of the functions pass an error to its callback (callback first parameter is not null), the main callback is immediately called with the value of the error. All functions will be executed though.
With the following code your execution will be as follows 1, 3, 2, 2.1
:
var async = require('async');
async.parallel([
function(cb) {
console.info('1')
cb(true);
},
function(cb) {
console.info('2')
cb(null, true);
},
function(cb) {
console.info('2.1')
cb(null, true);
}],
function(error, results) {
console.info('3')
}
);