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

pqueue-tiny

v0.2.1

Published

Tiny concurrency-limited promise queue with priorities, AbortSignal support, and onIdle(). Zero dependencies.

Readme

pqueue-tiny

ci

npm downloads bundle

A tiny concurrency-limited promise queue with priorities, AbortSignal support, and an onIdle() awaitable. Zero dependencies.

import { PQueue } from "pqueue-tiny";

const q = new PQueue({ concurrency: 5 });

for (const url of urls) {
  q.add(() => fetch(url));
}
await q.onIdle();

// With priority
q.add(() => urgent(), { priority: 10 });

// With per-task abort
const ac = new AbortController();
q.add(() => slowJob(), { signal: ac.signal });
ac.abort();  // cancels if not yet started

Install

npm install pqueue-tiny

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

Why

p-queue is excellent but ~10KB minified with lots of options you usually don't need. pqueue-tiny is ~150 lines covering 90% of real use cases: bounded concurrency, priorities, abort, idle waiting.

Recipes

Bulk URL fetcher (rate-limit kindness)

import { PQueue } from "pqueue-tiny";

async function fetchAll(urls: string[]) {
  const q = new PQueue({ concurrency: 5 });
  const results = urls.map((u) => q.add(() => fetch(u).then((r) => r.json())));
  return Promise.all(results);
}

Background queue with priorities

import { PQueue } from "pqueue-tiny";

const q = new PQueue({ concurrency: 2 });

// Background indexing — low priority
q.add(() => indexDocument(doc), { priority: 0 });

// User clicked save — high priority
q.add(() => saveImmediately(data), { priority: 100 });

Cancel a specific job

import { PQueue } from "pqueue-tiny";

const q = new PQueue({ concurrency: 1 });
const ac = new AbortController();

const promise = q.add(() => slowProcessing(), { signal: ac.signal });
// User cancels:
ac.abort(new Error("user cancelled"));
// `promise` rejects with that error if the job was still pending; if running, completes naturally.

Drain on shutdown

import { PQueue } from "pqueue-tiny";

const q = new PQueue({ concurrency: 4 });

process.on("SIGTERM", async () => {
  console.log(`draining ${q.inFlight} jobs...`);
  await q.onIdle();
  process.exit(0);
});

Combine with pmap-bounded

For sequential Promise.all semantics with concurrency, prefer pmap-bounded. For a long-lived job queue with priorities and abort, use pqueue-tiny.

API

new PQueue(opts?)

| Option | Type | Default | |---|---|---| | concurrency | number | 1 | | signal | AbortSignal | — — aborting cancels all pending tasks; running tasks are not interrupted |

q.add(fn, opts?): Promise<T>

| Option | Type | Default | |---|---|---| | priority | number | 0 — higher served first; FIFO within equal priority | | signal | AbortSignal | per-task; aborts only this task and only if it's still waiting |

Other methods / props

  • q.size — pending tasks waiting
  • q.pending — tasks currently running
  • q.inFlight — both combined
  • q.onIdle(): Promise<void> — resolves when both reach 0
  • q.clear() — drop waiting tasks (their promises reject)

Caveats

  • Aborting a queue doesn't kill running tasks — only refuses to schedule new ones and rejects waiting tasks. To kill a running task, pass its own signal to the underlying operation.
  • No retry built in — combine with @p-vbordei/pretry inside the task function.
  • In-memory only. For a persistent queue across restarts, use a real job queue (BullMQ, etc.).

License

Apache-2.0 © Vlad Bordei