Skip to content

array.map without parallelism; like async.mapSeries but for promises

License

Notifications You must be signed in to change notification settings

stefanpenner/promise-map-series

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promise-map-series

Build Status

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. The iterator will be called once for each element. If iterator returns a promise, then iterator will only be called for the next element once that promise is fulfilled. If the promise is rejected or iterator throws an error, iteration will stop immediately and mapSeries returns a rejected promise. The iterator function receives three arguments:

    • item: The current item in the array.

    • index: The current index in the array.

    • array: The original array argument.

  • thisArg (optional): Value to use as this when executing iterator.

About

array.map without parallelism; like async.mapSeries but for promises

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%