Version of async.series where each task receives the results of all previous tasks
See original GitHub issueI 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}
});
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Callback not getting called while using async.series
Async gives every single task a callback which you need to call to let async now that this task finished. After all tasks...
Read more >Understanding Node.js Async Flows: Parallel, Serial, Waterfall ...
Callback : This is the callback where all the task results are passed and executed once all the task execution has completed. The...
Read more >Clean Code NodeJs : Execute Asynchronous Tasks in Series
When all the tasks complete the execution, then the final callback will be called and return the results to the server.
Read more >Asynchronous flow control using async - MDN Web Docs
The method async.series() is used to run multiple asynchronous operations in sequence, when subsequent functions do not depend on the output of ...
Read more >Understanding Asynchronous Programming in Node.js | InformIT
The Async module has a method called series() that allows us to control the execution flow of callbacks. The series() method takes an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing this. I don’t think we need another method between
series
andwaterfall
in style.As I mentioned, in a simple series scenario async.auto is too verbose, The user have to declare that each step is dependent on the previous one, resulting in those ugly arrays and duplicate step names