Registry / devops / queue-promise

queue-promise

JSON →
library2.2.1jsnpmunverified

queue-promise (v2.2.1) is a minimal, zero-dependency library for managing concurrent promise-based queues in Node.js. It provides configurable concurrency (default 5) and interval (default 500ms) controls, task enqueuing/dequeuing, and event emission (start, stop, end, resolve, reject). Unlike heavier alternatives like Bull or bee-queue, it is dependency-free and suitable for simple in-process queueing. The library ships TypeScript definitions, has a stable release cadence, and supports both automatic and manual start modes. Compatible with Node >=8.12.0.

npm install queue-promise
INSTALL
IMPORT
SIG · QUEUE-PROMISE
Q
queue-promise
devopsjavascriptv2.2.1
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.

Queue
import Queue from 'queue-promise'
const Queue = require('queue-promise')
ESM default import; CommonJS require() works but may trigger bundler warnings. ESM-only in future versions?
QueueOptions
import type { QueueOptions } from 'queue-promise'
import { QueueOptions } from 'queue-promise'
QueueOptions is a TypeScript interface only; using runtime import will fail in TS.
Queue class (type)
import type { Queue } from 'queue-promise'
For type annotations, use type import to avoid bundling the class.

Creates a queue with concurrency 1 and 2-second interval, enqueues three async tasks, logs results.

import Queue from 'queue-promise'; const queue = new Queue({ concurrent: 1, interval: 2000 }); queue.on('resolve', data => console.log('Resolved:', data)); queue.on('reject', error => console.error('Rejected:', error)); const asyncTask = (ms) => () => new Promise(resolve => setTimeout(() => resolve(ms), ms)); queue.enqueue(asyncTask(100)); queue.enqueue(asyncTask(500)); queue.enqueue(asyncTask(300)); // Output: // Resolved: 100 // Resolved: 500 // Resolved: 300 queue.on('end', () => console.log('Queue finished'));
Debug
Known issues
breakingVersion 2.0.0 removed the default export of a factory function; now exports a class.
fix
Update import to `import Queue from 'queue-promise'` and instantiate with `new Queue(options)`.
affects: <2.0.0
deprecatedThe `add` method is an alias for `enqueue` and may be removed in future versions.
fix
Use `enqueue` instead.
affects: >=2.0.0
gotchaTasks must be functions returning Promises; passing a promise directly will execute it immediately and may cause unexpected behavior.
fix
Wrap promises in a function: `() => myPromise`.
affects: >=1.0.0
gotchaIf `start: false` is set, you must manually call `dequeue()` in a loop; forgetting to check `queue.shouldRun` may cause infinite loops or premature exit.
fix
Use `while (queue.shouldRun) { await queue.dequeue(); }`.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: queue.enqueue is not a function
Importing incorrectly as `{ Queue }` instead of default import.
fix
Use `import Queue from 'queue-promise'` instead of `import { Queue } from 'queue-promise'`.
UnhandledPromiseRejectionWarning: Error: Task must be an async function or return a promise
Passing a non-function (e.g., a promise directly) to `enqueue`.
fix
Wrap the promise in a function: `queue.enqueue(() => somePromise)`.
Upgrade
Version history
2.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
queue-promise — npm install queue-promise · libregistry