-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
I frequently encounter a situation where a async.series task need the results of several previous tasks. async.waterfall is insufficient since it only provides the result of the last previous task. async,auto is too verbose, and provides additional, unneeded dependency declaration.
A new function (or an improvment of async.series) would come in handy. Each task would receive a result object containing the results of all previous tasks
Possible names: accumulate, seriesAccumulate
Example:
async.accumulate({
one: function(callback){
setTimeout(function(){
callback(null, 1);
}, 200);
},
two: function(callback, results){
// results: {one: 1}
setTimeout(function(){
callback(null, 2);
}, 100);
},
three: function(callback, results){
// results: {one: 1, two: 2}
setTimeout(function(){
callback(null, results.one + results.two);
}, 100);
}
},
function(err, results) {
// results is now equal to: {one: 1, two: 2, three: 3}
});
zdila