The first is the series function, it is the function of serial execution, a function array of each function, each function is completed before executing the next function, the example is as follows:
Async.series ({ one:function (callback) { callback (null, 1); }, Two:function (callback) { Callback (null, 2); }},function (err, results) { });
The first parameter of the series function can be an array or a JSON object with different parameter types affecting the format of the returned data, such as the parameters in the example array, and the returned results should be such ' [.] '.
Waterfall (tasks, [callback])
There are many similarities between the waterfall and the series functions, in order to execute a set of functions sequentially, but the difference is that the value generated by each function is waterfall to the next function, and the series does not have this function, as shown in the following example:
Async.waterfall ([ function (callback) { //task1 callback (null,1); },function (Data,callback) { //task1 Callback (null,2); }],function (err,results) { console.log (results);});
It is also important to note that the tasks parameter of waterfall can only be an array type.
Parallel (tasks, [callback])
The parallel function executes multiple functions in parallel, and each function executes immediately, without waiting for other functions to execute first. The data in the array passed to the final callback is in the order declared in the tasks, not the order of completion, as shown in the following example:
Async.Parallel ([ function (callback) { callback (null, ' one '); }, function (callback) { callback (NULL, ' both '); }],function (err, results) {});
The tasks parameter can be an array or a JSON object, and as with the series function, the results format returned will be different for the tasks parameter types.
Parallel (tasks, [callback])
The parallel function executes multiple functions in parallel, and each function executes immediately, without waiting for other functions to execute first. The data in the array passed to the final callback is in the order declared in the tasks, not the order of completion, as shown in the following example:
Async.Parallel ([ function (callback) { callback (null, ' one '); }, function (callback) { Callback (NULL, ' both '); }],function (err, results) {});
The tasks parameter can be an array or a JSON object, and as with the series function, the results format returned will be different for the tasks parameter types.
Async Async Programming of Nodejs