Difference between async.each and async.eachSeries

Is async.each a working asynchronous iteration array?

Is async.eachSeries running in a synchronous array mode, iterating (it really expects a response)

I ask them because both have callbacks, but async.each works as an asynchronous array, iterating for ex:

//This is traditional way to iterate an array with callback functions in node.js
//Is this same with async.each ? i want to know it actually.

for (var i = 0; i < data.length; i++) {
 (function (i) {
  request(data[i],function(body){
   console.log(body)
  });
 })(i);

//if this codes and async.each are doing same things , 
//i know that async gives me an aert when all finished thats the difference.
+4
source share
2 answers

Your code example is most similar to what it does async.each, since all async calls requestare executed at the same time and allowed to continue in parallel.

async.eachSeries , async .

+7

async.eachSeries() .

, , , . , .

async.eachSeries(users, function(user, callback) {
  user.postProfileToServer(callback);
});

async.each() .

, , .

async.each(openFiles, saveFile, function(err){

});
+3

Source: https://habr.com/ru/post/1627686/


All Articles