Registry / testing / a-promise-queue

a-promise-queue

JSON →
library2.0.0jsnpmunverified

A lightweight, native ES6 promise queue library that supports concurrency, optional retry attempts for failed promises, and priority-based execution. Version 2.0.0 is the current stable release with an unknown release cadence. Unlike other promise queue libraries (e.g., p-limit or bottleneck), it offers built-in retry strategies and custom promise type support (e.g., Bluebird, Q). The library is primarily designed for Node.js and modern browsers with native Promise support.

npm install a-promise-queue
INSTALL
IMPORT
SIG · A-PROMISE-QUEUE
A
a-promise-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.

PromiseQueue
import PromiseQueue from 'a-promise-queue'
const { PromiseQueue } = require('a-promise-queue')
Default export only. Named import will result in undefined.
PromiseQueue (CommonJS)
const PromiseQueue = require('a-promise-queue')
const { default: PromiseQueue } = require('a-promise-queue')
CJS users should use default require; no destructuring.
options.promise
const queue = new PromiseQueue({ promise: require('bluebird') })
const queue = new PromiseQueue({ Promise: require('bluebird') })
The option key is lowercase 'promise', not 'Promise'. Incorrect casing silently defaults to native Promise.

Demonstrates creating a queue with a completion callback, adding tasks with different delays and priorities, and handling rejections.

import PromiseQueue from 'a-promise-queue'; const delay = (ms) => () => new Promise(resolve => setTimeout(resolve, ms)); const queue = new PromiseQueue(() => console.log('Queue is empty')); queue.add(delay(100)).then(() => console.log('first this')); queue.add(() => Promise.reject('then this fails')).catch((e) => console.log('Errored:', e)); queue.add(delay(10)).then(() => console.log('and this succeeds')); queue.add(delay(10), { priority: 1 }).then(() => console.log('but not before this one jumps the queue.')); // Wait for queue to finish queue.flush().then(() => console.log('All done'));
Debug
Known issues
gotchaOptions passed to constructor use lowercased keys (e.g., promise, concurrency). Common mistake: using 'Promise' instead of 'promise'.
fix
Use { promise: CustomPromise, concurrency: 3 } instead of { Promise: CustomPromise, Concurrency: 3 }.
affects: >=0.0.0
gotchaThe `attempts` option in `queue.add` is misspelled as 'attempts' (not 'attempts' or 'retries'). The doc uses 'attemps' but the correct option key is 'attempts'.
fix
Check your option spelling: use { attempts: 3 } instead of { retries: 3 } or { attempts: 3 }.
affects: >=0.0.0
gotchaPriority is only respected within the same flush; after flush() is called, new tasks wait until flush completes.
fix
Understand that priority ordering only applies to tasks added before a flush. Use separate queues if you need priority across flushes.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue.add is not a function
Using named import ({ PromiseQueue }) instead of default import.
fix
Use default import: import PromiseQueue from 'a-promise-queue'; or const PromiseQueue = require('a-promise-queue');
TypeError: options.concurrency is not a number
Passing concurrency option with misspelled key or as string.
fix
Ensure concurrency is a number and spelled correctly: { concurrency: 5 }
TypeError: promise.then is not a function
Passing a non-Promise value or invalid promise type in options.promise.
fix
Pass a valid Promise constructor as options.promise, e.g., require('bluebird') or use native Promise.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
40
OpenAI (training)
1
Resources
a-promise-queue — npm install a-promise-queue · libregistry