npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pmap-bounded

v0.2.1

Published

Bounded-concurrency Promise.all and Promise.allSettled. AbortSignal support, optional collect-all-errors mode. Zero dependencies.

Downloads

19

Readme

pmap-bounded

ci

npm downloads bundle

Promise.all and Promise.allSettled with a concurrency limit, AbortSignal support, and an optional collect-all-errors mode. Zero dependencies.

import { pmap, pmapSettled } from "pmap-bounded";

const responses = await pmap(urls, (u) => fetch(u), { concurrency: 5 });

const results = await pmap(items, work, {
  concurrency: 10,
  stopOnError: false,
});

const settled = await pmapSettled(items, work, { concurrency: 4 });
for (const r of settled) {
  if (r.status === "fulfilled") use(r.value);
  else                          log(r.reason);
}

Install

npm install pmap-bounded

Works with Node 20+, browsers, Bun, Deno. ESM + CJS.

Why

Promise.all runs everything in parallel — which for a thousand URLs is a thousand simultaneous fetches. That hits rate limits, exhausts file descriptors, or hammers the database.

pmap-bounded is Promise.all with a knob: concurrency: 10. Plus the things you actually want in real code:

  • AbortSignal to cancel the whole batch
  • stopOnError: false to keep going and aggregate errors
  • pmapSettled for "never throw, return per-item status"
  • Preserves input order in the output array

Recipes

Bulk fetch with rate limiting

import { pmap } from "pmap-bounded";

const responses = await pmap(
  urls,
  async (u) => {
    const r = await fetch(u);
    return r.json();
  },
  { concurrency: 5 },
);

Process all, collect errors instead of failing fast

import { pmap } from "pmap-bounded";

try {
  const okResults = await pmap(items, work, { concurrency: 10, stopOnError: false });
} catch (err) {
  if (err instanceof AggregateError) {
    console.error(`${err.errors.length} failed:`);
    for (const e of err.errors) console.error(e);
  }
}

Use settled when you want per-item status without throwing

import { pmapSettled } from "pmap-bounded";

const results = await pmapSettled(urls, fetch, { concurrency: 5 });
const successes = results.filter((r) => r.status === "fulfilled").length;
console.log(`${successes}/${results.length} succeeded`);

Total deadline

import { pmap } from "pmap-bounded";

const totalDeadline = AbortSignal.timeout(30_000);

const results = await pmap(items, work, {
  concurrency: 5,
  signal: totalDeadline,
});
// Throws with the timeout reason if 30s elapses before completion

Combine with pretry

import { pmap } from "pmap-bounded";
import { retry, isRetriableHttpError } from "@p-vbordei/pretry";

await pmap(
  urls,
  (u) => retry(() => fetch(u), { retryOn: isRetriableHttpError }),
  { concurrency: 5 },
);

API

pmap(items, mapper, opts?): Promise<R[]>

Preserves input order. The mapper receives (item, index).

| Option | Type | Default | Meaning | |---|---|---|---| | concurrency | number | Infinity | Max in-flight mappers | | stopOnError | boolean | true | If false, all items are processed; an AggregateError is thrown at the end | | signal | AbortSignal | — | Aborts the operation |

pmapSettled(items, mapper, opts?): Promise<PromiseSettledResult<R>[]>

Same options minus stopOnError. Returns one settled result per input. Only the signal abort can cause it to reject.

When to use what

| Want | Use | |---|---| | Bounded Promise.all semantics, fail-fast | pmap(...) | | Bounded Promise.all, collect-all errors | pmap(..., { stopOnError: false }) → throws AggregateError | | Bounded Promise.allSettled semantics | pmapSettled(...) | | Job queue with priorities, abort, idle awaiting | pqueue-tiny |

License

Apache-2.0 © Vlad Bordei