Back to Explore

sindresorhus/p-map

GitHub
4 updates · last 90 daysOpen source

Last release:

p-map (sindresorhus/p-map) is a JavaScript utility for mapping over promises concurrently. It’s useful for running async functions over many inputs while controlling concurrency, handling errors (stop on first error or collect all errors), and optionally using an AbortSignal to cancel.

Project status

  • Actively maintained and actively updated: The repo’s most recent upstream push and the latest updates are on 2026-10-11, with additional recent updates on 2026-10-09, 2026-09-12, and 2026-08-27, indicating ongoing maintenance rather than a dormant period.
  • Update cadence looks healthy (relative to 2026-10-15): There are multiple updates within a few months (roughly late August through mid October 2026), with smaller, continuing fixes back through mid-2026.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v7.1.1

    v7.1.1 changes p-map’s internal handling of async iterables whose `next()` returns a thenable, so the library subscribes only once per pull. The release also updates TypeScript and README documentation with clarification about `await using` and `Symbol.asyncDispose` behavior for the iterable returned by p-map.

  • v7.1.0

    v7.1.0 adds new p-map variants to mirror Promise.allSettled and the Promise.allKeyed/Promise.allSettledKeyed APIs, plus new control over pMapIterable ordering via preserveOrder. It also refactors the internal concurrency and backpressure engine for more deterministic behavior, better stack traces, and improved algorithmic performance for consuming results.

    Features
  • v7.0.8

    v7.0.8 focuses on fixing iterator lifecycle issues in both `pMap` and `pMapIterable`, including preventing hangs after the source iterator is exhausted, and ensuring iterators are properly closed. It also adds fixes to stop spawning work after the consumer stops iterating, and improves error handling behavior around `stopOnError: false`.

  • v7.0.7

    v7.0.7 fixes an unhandled rejection scenario in `pMapIterable` when a consumer stops early while an in-flight `iterator.next()` is still pending. The change ensures that errors from abandoned workers are handled deterministically rather than surfacing as unhandled promise rejections.

  • v7.0.6

    This release (v7.0.6) fixes an abort handling edge case in p-map when the provided AbortSignal is already aborted. The change prevents an unnecessary abort event listener from being registered in that scenario, aligning runtime behavior with the intended cleanup.

  • v7.0.5

    This release, v7.0.5, fixes an issue in `pMapIterable` where the `index` passed to the mapper could be incorrect when the input is a list of promises that settle out of order. The implementation change ensures indices are assigned in the order items are pulled, not in the order their awaited promises resolve. Release notes also include small documentation updates and a new test covering out-of-order settlement.

  • v7.0.4

    v7.0.4 contains a targeted fix to concurrency control in `pMapIterable`. The code change adjusts how the in-flight work count is tracked so that backpressure and concurrency are enforced correctly for async iterables, and it adds a regression test for the case where `backpressure > concurrency`.

  • v7.0.3

    v7.0.3 makes a targeted fix for how pMap handles AbortController abort events, specifically around cleaning up the abort listener. It updates the promise resolution/rejection flow to remove the abort listener after the operation settles.

  • v7.0.2

    v7.0.2 updates p-map to supply an `index` argument to the mapper function used by `pMapIterable`. The release notes describe the change, and the code and tests confirm it was implemented.

  • v7.0.1

    v7.0.1 is a small patch release focused on fixing pMapIterable when the iterator yields async values (promises). The runtime change ensures the mapper receives resolved values, alongside minor docs/test updates.

  • v7.0.0

    v7.0.0 raises the minimum supported Node.js version to 18 and introduces a new streaming API, pMapIterable, for mapping over (async) iterables with concurrency control. The implementation also adds an additional backpressure option to limit how many mapper results are buffered ahead of the consumer.

    BreakingFeatures
  • v6.0.0

    v6.0.0 raises the minimum supported Node.js version to 16 and changes the aggregated error implementation used when `stopOnError: false`. The release notes also indicate a behavioral difference in the aggregated error message compared to the previously used `aggregate-error` package.

    Breaking
  • v5.5.0

    Release v5.5.0 updates the public TypeScript typings for p-map. The main documented change is that `Mapper` can now return `pMapSkip` to signal that an item should be skipped.

    Features
  • v5.4.0

    Release v5.4.0 adds support for aborting `pMap` operations via `AbortController` by introducing an optional `signal` option. The core implementation wires the provided `AbortSignal` into `pMap` so it rejects when aborted.

    Features