Promise queue with concurrency control for rate-limiting async operations. Stable version 6.2.4, ships TypeScript definitions, requires Node >=8. Actively maintained (by sindresorhus). Key differentiators: optional priority, interval-based rate limiting, timeout support, and custom queue classes. ESM-only since v7, but v6 supports both ESM and CJS.
npm install pm-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: create a queue with concurrency=2 and rate limit of 5 tasks per second, then add 10 async tasks.
Update imports to ES module syntax: import PQueue from 'p-queue'. If you must use CJS, stick with v6.x or use dynamic import().
Use the 'Queue' class option instead: new PQueue({ queue: new PriorityQueue() })Treat .addAll() similarly to Promise.all; it will reject if any task throws.
Explicitly call queue.start() after adding tasks, or set autoStart: true in options.
Ensure the function passed to .add() returns a promise (async or .then()).
Use new PQueue() instead of calling PQueue() without new.
Run 'npm install p-queue' and ensure you are in the correct directory.
Use const { default: PQueue } = require('p-queue') or import PQueue from 'p-queue'.