Map over array avoiding parallel execution, using promises
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.
npm install --save promise-map-series
var mapSeries = require'promise-map-series'mapSeriesarray iterator thisArgthen
array: An array of values (should not be promises).
iterator: Function that returns a promise or a value for the new array. The
iteratorwill be called once for each element. If
iteratorreturns a promise, then
iteratorwill only be called for the next element once that promise is fulfilled. If the promise is rejected or
iteratorthrows an error, iteration will stop immediately and
mapSeriesreturns a rejected promise. The
iteratorfunction receives three arguments:
item: The current item in the array.
index: The current index in the array.
array: The original
thisArg(optional): Value to use as