install-nix-action/node_modules/p-each-series
Domen Kožar 08403cd828
v5
2019-11-13 17:14:48 +01:00
..
index.js v5 2019-11-13 17:14:48 +01:00
license v5 2019-11-13 17:14:48 +01:00
package.json v5 2019-11-13 17:14:48 +01:00
readme.md v5 2019-11-13 17:14:48 +01:00

p-each-series Build Status

Iterate over promises serially

Useful as a side-effect iterator. Prefer p-map if you don't need side-effects, as it's concurrent.

Install

$ npm install --save p-each-series

Usage

const pEachSeries = require('p-each-series');

const keywords = [
	getTopKeyword() //=> Promise
	'rainbow',
	'pony'
];

const iterator = el => saveToDiskPromise(el); //=> Promise

pEachSeries(keywords, iterator).then(result => {
	console.log(result);
	//=> ['unicorn', 'rainbow', 'pony']
});

API

pEachSeries(input, iterator)

Returns a Promise that is fulfilled when all promises in input and ones returned from iterator are fulfilled, or rejects if any of the promises reject. The fulfillment value is the original input.

input

Type: Iterable<Promise|any>

Iterated over serially in the iterator function.

iterator(element, index)

Type: Function

Return value is ignored unless it's Promise, then it's awaited before continuing with the next iteration.

  • p-map-series - Map over promises serially
  • p-pipe - Compose promise-returning & async functions into a reusable pipeline
  • p-reduce - Reduce a list of values using promises into a promise for a value
  • p-map - Map over promises concurrently
  • More…

License

MIT © Sindre Sorhus