Registry / devops / queue-up

queue-up

JSON →
library2.1.0jsnpmunverified

Simple promise-based function queue for rate-limited execution. Version 2.1.0, stable, with low release cadence. Each enqueued function resolves after a configurable interval from the previous function's resolution. Supports initial value passing between chained functions. Lightweight, no dependencies. Unlike throttle/debounce, it queues calls to ensure spacing but never drops them.

npm install queue-up
INSTALL
IMPORT
SIG · QUEUE-UP
Q
queue-up
devopsjavascriptv2.1.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.

Queue
✓ const Queue = require('queue-up');
✗ import Queue from 'queue-up';
Package uses CommonJS; no default ESM export. In Node ≥12 with type:module, use createRequire or dynamic import. For TypeScript, use `import Queue = require('queue-up')`.
queue.up()
✓ queue.up(() => asyncFn());
✗ queue.up(asyncFn());
Pass a function reference or arrow function, not the result of calling the function. The queue expects a function to invoke later.
queue.all()
✓ queue.all([fn1, fn2]);
Takes an iterable (e.g., array) of functions. Returns promise resolving to array of results in order.

Creates a queue with 200ms interval and enqueues two async functions to demonstrate spacing.

const Queue = require('queue-up'); const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); async function fetchUser(id) { await delay(100); return { id, name: `User${id}` }; } const queue = new Queue(200); // 200ms interval between functions queue.up(() => fetchUser(1)).then(user => console.log('First:', user.name)); queue.up(() => fetchUser(2)).then(user => console.log('Second:', user.name)); // First logs immediately, Second logs after ~200ms
Debug
Known issues
gotchaThe interval is measured from the resolution of the previous function to the invocation of the next, not from the start of execution.
fix
Understand that long-running functions will cause subsequent functions to be delayed further. The total delay accumulates.
affects: all
gotchaIf the enqueued function throws or rejects, the queue continues; the error is propagated to the promise returned by queue.up() but does not stop the queue.
fix
Always attach a .catch() to each queue.up() promise or handle errors inside the function.
affects: all
gotchaqueue.up() does not accept a promise; it must receive a function that returns a promise (or any value). Passing a promise directly will cause unexpected behavior.
fix
Wrap the promise in an arrow function: queue.up(() => somePromise);
affects: all
deprecatedqueue.enqueue() is an alias for queue.up() but may be removed in future versions.
fix
Use queue.up() instead of queue.enqueue().
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: queue.up is not a function
Using default import style in Node.js or bundler expecting a default export, but the package exports a constructor as module.exports.
fix
Use const Queue = require('queue-up'); and then const queue = new Queue();
UnhandledPromiseRejectionWarning: Error: something failed
A function enqueued via queue.up() threw an error and the returned promise was not caught.
fix
Attach a catch handler: queue.up(fn).catch(err => console.error(err));
Error: fn is not a function
Passing a non-function value (e.g., a promise or a result) to queue.up().
fix
Ensure you pass a function reference or arrow function: queue.up(() => myAsyncFunction());
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
queue-up — npm install queue-up · libregistry