p-each-series

WebJar for p-each-series

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

p-each-series
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

p-each-series
WebJar for p-each-series
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/p-each-series

Download p-each-series

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/p-each-series/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>p-each-series</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/p-each-series/
implementation 'org.webjars.npm:p-each-series:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/p-each-series/
implementation ("org.webjars.npm:p-each-series:1.0.0")
'org.webjars.npm:p-each-series:jar:1.0.0'
<dependency org="org.webjars.npm" name="p-each-series" rev="1.0.0">
  <artifact name="p-each-series" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='p-each-series', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "p-each-series" % "1.0.0"
[org.webjars.npm/p-each-series "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : p-reduce jar [1.0.0,2)

Project Modules

There are no modules declared in this project.

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 p-each-series

Usage

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

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

const iterator = async element => saveToDiskPromise(element);

(async () => {
	console.log(await pEachSeries(keywords, iterator));
	//=> ['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 | unknown>

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.

pEachSeries.stop

Stop iterating through items by returning pEachSeries.stop from the iterator function.

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

// Logs `a` and `b`.
const result = await pEachSeries(['a', 'b', 'c'], value => {
	console.log(value);

	if (value === 'b') {
		return pEachSeries.stop;
	}
});

console.log(result);
//=> ['a', 'b', 'c']

Related

  • p-map-series - Map over promises serially
  • p-series - Run promise-returning & async functions in series
  • p-pipe - Compose promise-returning & async functions into a reusable pipeline
  • p-waterfall - Run promise-returning & async functions in series, each passing its result to the next
  • p-reduce - Reduce a list of values using promises into a promise for a value
  • p-map - Map over promises concurrently
  • More…

Versions

Version
1.0.0