Registry / testing / promise-pull-queue

promise-pull-queue

JSON →
library2.0.0jsnpmunverified

A lightweight promise queue library (v2.0.0) for pull-based async task handling. Pushed promises are resolved in FIFO order when pulled. Supports abort via AbortController. Ships TypeScript type definitions. ESM and CJS compatible. Key differentiator: designed specifically for pull-based patterns where consumers wait for results before producers push them, unlike push-based queues (e.g., p-limit, p-queue).

npm install promise-pull-queue
INSTALL
IMPORT
SIG · PROMISE-PULL-QUEUE
P
promise-pull-queue
testingjavascriptv2.0.0
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.

PullQueue
import PullQueue from 'promise-pull-queue'
const PullQueue = require('promise-pull-queue')
Default export. For CommonJS, use require('promise-pull-queue').default.
PullQueue
const PullQueue = require('promise-pull-queue').default
const { PullQueue } = require('promise-pull-queue')
CommonJS require pattern; default export is not named.

Creates a pull queue, pushes promises, and pulls results in order. Demonstrates push-then-pull, deferred resolution, and late push.

import PullQueue from 'promise-pull-queue'; const queue = PullQueue(); queue.push(Promise.resolve(1)); queue.push(Promise.resolve(2)); const p3 = new Promise(resolve => setTimeout(() => resolve(3), 100)); queue.push(p3); setTimeout(() => { queue.push(Promise.resolve(4)); }, 200); async function main() { const result1 = await queue.pull(); // 1 const result2 = await queue.pull(); // 2 const result3 = await queue.pull(); // 3 (after ~100ms) const result4 = await queue.pull(); // 4 (after ~200ms) console.log(result1, result2, result3, result4); } main();
Debug
Known issues
breakingv2.0.0 changed import path and removed .default in ESM
fix
Use default import in ESM: import PullQueue from 'promise-pull-queue' or CommonJS: require('promise-pull-queue').default
affects: >=2.0.0
deprecatedUsing pull() without arguments is fine; but if passing an AbortSignal, ensure it is a valid AbortSignal or the promise may never reject.
fix
Pass a valid AbortSignal: queue.pull(signal). If signal is already aborted, pull will reject immediately.
affects: >=2.0.0
gotchaCalling pull() before any push() will hang indefinitely unless a new promise is pushed later. The queue does not have a timeout or close mechanism.
fix
Always ensure that eventually a push occurs, or use AbortController to cancel pending pulls.
affects: >=0.0.0
gotchapush() expects a promise; passing a non-promise value may cause unexpected behavior (e.g., not waiting)
fix
Always wrap non-promise values in Promise.resolve(): queue.push(Promise.resolve(value))
affects: >=0.0.0
Errors
Common errors & fixes
const PullQueue = require('promise-pull-queue'); TypeError: PullQueue is not a function
In CommonJS, require returns an object with a 'default' property.
fix
Change to: const PullQueue = require('promise-pull-queue').default;
TypeError: queue.pull is not a function
Forgetting to call PullQueue() constructor (missing parentheses).
fix
Change to: const queue = PullQueue();
UnhandledPromiseRejection: AbortError: aborted
Calling pull() with an already-aborted AbortSignal.
fix
Check signal.aborted before pulling, or handle the rejection properly.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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