Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  110] [ 7]  / answers: 1 / hits: 21376  / 8 Years ago, sun, february 7, 2016, 12:00:00

Is async.each working as asynchronous array iterating?



Is async.eachSeries working as synchronous array iterating?(it waits response actually)



I'm asking these because both have callbacks but async.each works like 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.

More From » node.js

 Answers
7

Your code example is most similar to what async.each does, as all the async request calls are made at once and allowed to proceed in parallel.



The difference with async.eachSeries is that each iteration will wait for the async operation to complete before starting the next one.


[#63404] Friday, February 5, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
masonm

Total Points: 167
Total Questions: 87
Total Answers: 103

Location: Rwanda
Member since Wed, Jun 8, 2022
2 Years ago
masonm questions
;