Registry / testing / queue-that-promise

queue-that-promise

JSON →
library1.2.3jsnpmunverified

A minimal promise queue that ensures callbacks execute sequentially in order of addition. Current stable version is 1.2.3, with a simple API consisting of add(), done(), and count(). It is lightweight at 500 bytes gzipped and has no dependencies. This differs from larger queue libraries by focusing solely on promise-based serialization without concurrency control or priorities. The project is in maintenance mode with infrequent updates.

npm install queue-that-promise
INSTALL
IMPORT
SIG · QUEUE-THAT-PROMISE
Q
queue-that-promise
testingjavascriptv1.2.3
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
const Queue = require('queue-that-promise')
import Queue from 'queue-that-promise'
Package is CommonJS only; ESM import will fail.
Queue
import Queue from 'queue-that-promise'
const { Queue } = require('queue-that-promise')
Package uses default export only; named destructuring will result in undefined.
queue.add
const promise = queue.add(() => asyncTask())
queue.add(promise())
add() expects a function that returns a promise, not a promise itself.

Creates a queue, adds three promise-returning callbacks that log sequentially, and waits for all to complete.

const Queue = require('queue-that-promise'); const queue = Queue(); queue.add(() => new Promise(resolve => setTimeout(() => { console.log('first'); resolve(); }, 100))); queue.add(() => new Promise(resolve => setTimeout(() => { console.log('second'); resolve(); }, 100))); queue.add(() => new Promise(resolve => setTimeout(() => { console.log('third'); resolve(); }, 100))); queue.done().then(() => console.log('done'));
Debug
Known issues
gotchaPassing a promise directly to queue.add() will execute it immediately, not in queue order.
fix
Wrap the promise in a function: queue.add(() => myPromise)
affects: >=1.0.0
gotchaqueue.done() only waits for callbacks added before it; callbacks added after will not be waited on.
fix
Call queue.done() after all add() calls, or re-await done() after subsequent adds.
affects: >=1.0.0
gotchaThe queue does not have concurrency control; all tasks run serially by design.
fix
For parallel processing, use Promise.all or a library like p-limit.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: queue.add is not a function
Importing as named export instead of default.
fix
Use const Queue = require('queue-that-promise'); const queue = Queue();
UnhandledPromiseRejectionWarning: Error: ...
Rejection in a callback is not caught unless .catch is chained on queue.add()'s returned promise.
fix
Handle errors: queue.add(callback).catch(err => console.error(err));
ReferenceError: queue is not defined
Forgot to instantiate the queue with Queue().
fix
const queue = Queue();
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

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