This is not

Like what you see? Install OctoLinker now!

Skip to content
Map over promises serially
JavaScript TypeScript
Branch: master
Clone or download
Latest commit 7339a5f Sep 10, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes Require Node.js 8, add TypeScript definition (#1) Mar 15, 2019
.travis.yml Require Node.js 8, add TypeScript definition (#1) Mar 15, 2019
index.test-d.ts Refactor TypeScript definition to CommonJS compatible export (#2) Apr 3, 2019
package.json 2.1.0 Apr 3, 2019

p-map-series Build Status

Map over promises serially

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


$ npm install p-map-series


const pMapSeries = require('p-map-series');

const keywords = [
	getTopKeyword() //=> Promise

let scores = [];

const mapper = async keyword => {
	const score = await fetchScore(keyword);
	return {keyword, score};

(async () => {
	console.log(await pMapSeries(keywords, mapper));
			keyword: 'unicorn',
			score: 99
			keyword: 'rainbow',
			score: 70
			keyword: 'pony',
			score: 79


pMapSeries(input, mapper)

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


Type: Iterable<Promise | unknown>

Mapped over serially in the mapper function.

mapper(element, index)

Type: Function

Expected to return a value. If it's a Promise, it's awaited before continuing with the next iteration.


  • p-each-series - Iterate over promises serially
  • p-reduce - Reduce a list of values using promises into a promise for a value
  • p-map - Map over promises concurrently
  • More…

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
You can’t perform that action at this time.