Await Each
Iterate async functions!
;
Will wait until each callback is resolved before iterating to the next.
No dependency on async
functions!
Can also be used with just promises:
;
Mixin with underscore:
_;
Install
npm install await-each --save
Why?
How is this any different than:
values;
In the code above, each callback will wait for it's own await
to resolve before continuing, but that wont stop the next callback from starting.
Consider this code:
values;
Because each iteration does not wait for the previous the output would likely be something like:
A A A B B B
Using awaitEach
, each iteration waits for the prev to resolve before starting.
So converting the above code to:
;
Will guarantee the output will be:
A B A B A B