Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

p-each-series

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

p-each-series

Iterate over promises serially

    3.0.0latest

Version published
Maintainers
1
Weekly downloads
6,743,155
decreased by-10.1%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 12 5312b08
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/p-each-series/compare/v2.2.0...v3.0.0

Readme

Source

p-each-series

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

import pEachSeries from 'p-each-series'; const keywords = [ getTopKeyword(), //=> Promise 'rainbow', 'pony' ]; const iterator = async element => saveToDiskPromise(element); 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.

import pEachSeries from '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']
  • 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…

Keywords

FAQs

What is p-each-series?

Iterate over promises serially

Is p-each-series popular?

The npm package p-each-series receives a total of 6,449,806 weekly downloads. As such, p-each-series popularity was classified as popular.

Is p-each-series well maintained?

We found that p-each-series demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 09 Apr 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc