promise-map-series
Call an iterator function for each element of an array in series, ensuring that no iterator is called before the promise returned by the previous iterator is fulfilled, in effect preventing parallel execution. Like async.mapSeries, but for promises.
Installation
npm install --save promise-map-series
Usage
var mapSeries = require('promise-map-series')
mapSeries(array, iterator[, thisArg]).then(function (newArray) {
...
})
-
array: An array of values (should not be promises). -
iterator: Function that returns a promise or a value for the new array. Theiteratorwill be called once for each element. Ifiteratorreturns a promise, theniteratorwill only be called for the next element once that promise is fulfilled. If the promise is rejected oriteratorthrows an error, iteration will stop immediately andmapSeriesreturns a rejected promise. Theiteratorfunction receives three arguments:-
item: The current item in the array. -
index: The current index in the array. -
array: The originalarrayargument.
-
-
thisArg(optional): Value to use asthiswhen executingiterator.
