Registry / devops / p-queue-compat

p-queue-compat

JSON →
library1.0.234jsnpmunverified

A drop-in compatible fork of the p-queue library (v7.x) that provides both CommonJS and ES module exports. Version 1.0.234 is current, published frequently. It wraps the original p-queue with no API changes, offering concurrency control, rate limiting, priority queues, and timeout support. The main differentiator is that it restores CJS support (dropped in p-queue v7) while maintaining all original features including EventEmitter3-based events, custom queue classes, and interval-based throttling. Actively maintained with weekly releases.

npm install p-queue-compat
INSTALL
IMPORT
SIG · P-QUEUE-COMPAT
P
p-queue-compat
devopsjavascriptv1.0.234
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PQueue
import PQueue from 'p-queue-compat'
const PQueue = require('p-queue-compat') (CJS works but ESM preferred)
Default import works in both CJS and ESM contexts
PQueue
const PQueue = require('p-queue-compat')
CJS require supported unlike p-queue v7+
PriorityQueue
import {PriorityQueue} from 'p-queue-compat'
import PriorityQueue from 'p-queue-compat'
Named export for optional priority queue class

Shows concurrency + rate limiting (2 concurrent, max 5 per sec), fetch with queue, and queue stats.

import PQueue from 'p-queue-compat'; import fetch from 'node-fetch'; const queue = new PQueue({ concurrency: 2, interval: 1000, intervalCap: 5 }); const urls = ['https://example.com', 'https://httpbin.org/get', 'https://jsonplaceholder.typicode.com/todos/1']; async function fetchUrl(url) { const response = await fetch(url); return response.text(); } const promises = urls.map(url => queue.add(() => fetchUrl(url))); (async () => { const results = await Promise.all(promises); console.log('Results:', results); console.log('Queue size remaining:', queue.size); console.log('Pending:', queue.pending); })();
Debug
Known issues
breakingp-queue v7 is ESM-only and drops CommonJS. p-queue-compat restores CJS support but follows same API.
fix
Use p-queue-compat >=1.0.0 for CJS compatibility.
affects: <1.0.0
deprecatedThe default queue class (ArrayQueue) is deprecated in favor of PriorityQueue.
fix
Use PriorityQueue from 'p-queue-compat' explicitly if you need priority ordering.
affects: >=7.0.0
gotchaTimeout option applies per-operation when dequeued, not while waiting in queue.
fix
Set timeout on task add() or constructor; tasks in queue waiting do not timeout.
affects: all
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Using ESM import in a CommonJS file
fix
Use require('p-queue-compat') or add "type": "module" to package.json
TypeError: PQueue is not a constructor
Incorrect import: default import used as named
fix
Use import PQueue from 'p-queue-compat' (default), not import { PQueue } from 'p-queue-compat'
Error: ERR_REQUIRE_ESM
Trying to require() an ES module in Node <12 or without proper loader
fix
Use p-queue-compat which provides CJS, or use dynamic import()
Upgrade
Version history
1.0.234latest on npm
Audit
Dependencies
eventemitter3requiredUsed by p-queue internally for event support
Agent activity
2 hits · last 30 days
node
2
Resources
p-queue-compat — npm install p-queue-compat · libregistry