github →

Request

Issue #31

draft pr open
Verification
Verified — checks passed

We installed dependencies and ran test in a sandbox — all passed.

Likely addresses the issue (95% confidence)

An AI estimate of whether the change actually fixes the issue — the checks themselves only confirm nothing broke. It's a hint for review, not a pass/fail check.

Why?

The diff introduces `pMapStop` as a Symbol that can be returned from a `mapper` function to halt further iteration. In both the main `pMap` and `pMapIterable` functions, returning `pMapStop` sets an `isStopped` flag that prevents new items from being consumed from the iterator while allowing already-started mappers to finish, and the stopping element is excluded from results—exactly fulfilling the core ask in Issue #31. The secondary suggestions about placeholder values for uncomputed items were optional (framed as 'could be') and their omission does not leave the core feature incomplete.

  • testpassed · 20.7s
    > p-map@7.0.4 test
    > xo && ava && tsd
    
    
      ✔ test › handles empty iterable
      ✔ test › asyncIterator - handles empty iterable
      ✔ test › pMapIterable - empty
      ✔ test › pMapStop - at start
      ✔ test › invalid mapper
      ✔ test › already aborted signal
      ✔ test › pMapIterable - iterable that throws
      ✔ test › pMapSkip
      ✔ test › pMapIterable - mapper that throws
      ✔ test › all pMapSkips
      ✔ test › pMapStop
      ✔ test › multiple pMapSkips
      ✔ test › pMapIterable - pMapSkip
      ✔ test › pMapStop - with pMapSkip
      ✔ test › pMapIterable - pMapStop
      ✔ test › enforce number in options.concurrency
      ✔ test › asyncIterator - enforce number in options.concurrency
      ✔ test › asyncIterator - pMapSkip
      ✔ test › pMapStop - async iterator
      ✔ test › abort by AbortController (104ms)
      ✔ test › asyncIterator - all pMapSkips (110ms)
      ✔ test › no unhandled rejected promises from mapper throws - infinite concurrency (138ms)
      ✔ test › no unhandled rejected promises from mapper throws - concurrency 1 (140ms)
      ✔ test › pMapIterable - stop on error (131ms)
      ✔ test › asyncIterator - multiple pMapSkips (153ms)
      ✔ multiple-pmapskips-performance › multiple pMapSkips - algorithmic complexity (261ms)
      ✔ test › async with concurrency: 2 (out of order time sequence) (242ms)
      ✔ test › async with concurrency: 2 (problematic time sequence) (251ms)
      ✔ test › asyncIterator - async with concurrency: 2 (out of order time sequence) (259ms)
      ✔ test › asyncIterator - async with concurrency: 2 (problematic time sequence) (306ms)
      ✔ test › asyncIterator - async with concurrency: 2 (random time sequence) (311ms)
      ✔ test › async with concurrency: 2 (random time sequence) (338ms)
      ✔ test › main (360ms)
      ✔ test › pMapIterable (324ms)
      ✔ test › catches exception from source iterator - 1st item (347ms)
      ✔ test › pMapIterable - async input, backpressure > concurrency (331ms)
      ✔ test › asyncIterator - main (360ms)
      ✔ test › pMapIterable - concurrency: 2 (372ms)
      ✔ test › catches exception from source iterator - 2nd item (440ms)
      ✔ test › catches exception from source iterator - 2nd item after 1st item mapper throw (440ms)
      ✔ test › asyncIterator - get the correct exception after stop-on-error (499ms)
      ✔ test › incorrect input type (501ms)
      ✔ test › immediately rejects when stopOnError is true (564ms)
      ✔ test › asyncIterator - immediately rejects when stopOnError is true (619ms)
      ✔ test › all mappers should run when concurrency is infinite, even after stop-on-error happened (640ms)
      ✔ test › pMapIterable - index in mapper (624ms)
      ✔ test › concurrency: 1 (658ms)
      ✔ test › pMapIterable - concurrency: 1 (624ms)
      ✔ test › asyncIterator - all mappers should run when concurrency is infinite, even after stop-on-error happened (659ms)
      ✔ test › asyncIterator - concurrency: 1 (680ms)
      ✔ test › pMapStop - concurrency (684ms)
      ✔ test › pMapIterable - pMapStop - concurrency (711ms)
      ✔ test › pMapIterable - backpressure (1s)
      ✔ test › aggregate errors when stopOnError is false (1.2s)
      ✔ test › asyncIterator - aggregate errors when stopOnError is false (1.4s)
      ✔ test › concurrency: 4 (2.6s)
      ✔ test › asyncIterator - concurrency: 4 (3.1s)
      ─
    
      57 tests passed

lint, typecheck, and build are not defined separately in this repo.

Ran 6/4/2026, 10:00:33 PM · npm

Get the code

Pull this branch
With gh CLI
gh pr checkout 1 --repo muazHL/p-map
Raw git
git fetch https://github.com/muazHL/p-map.git gitgot/issue-31
git checkout -b gitgot/issue-31 FETCH_HEAD

Fork-mode request: the branch lives on muazHL/p-map (your fork), not sindresorhus/p-map, so the commands above target the fork.

Drive locally

Paste this into your local coding agent (Claude Code, Cursor, etc.) to continue iterating with full repo context.

Context prompt
You are continuing work on a draft PR for sindresorhus/p-map, addressing issue #31.

First, check out the branch with gitgot's first-pass change (run from a clone of the repo):
  gh pr checkout 1 --repo muazHL/p-map

Then review the diff and:
- run the project's lint/typecheck/test commands and fix anything broken
- if the diff is wrong-headed, revert it and start fresh from the issue
- keep the change tight; do not refactor unrelated code
PR thread
  • No comments on the PR yet. Use the form below to start the thread.