Registry / productivity / ca11back-queue

ca11back-queue

JSON →
library3.0.0jsnpmunverified

A synchronous execution queue for asynchronous callbacks that prevents event loop blocking. Version 3.0.0, stable, uses a manual next() pattern similar to Express middleware. The first pushed callback executes immediately; subsequent calls are queued. Supports initArgs for default arguments across all callbacks and argument passing via push() and next(). Unlike async.queue or p-limit, it enforces sequential execution with explicit next invocation. Requires Node >14.0.0.

npm install ca11back-queue
INSTALL
IMPORT
SIG · CA11BACK-QUEUE
C
ca11back-queue
productivityjavascriptv3.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.

CallbackQueue
const CallbackQueue = require('ca11back-queue');
import CallbackQueue from 'ca11back-queue';
v3 uses CommonJS; no default ESM export.
callbackQueue.push
const queue = new CallbackQueue(); queue.push((next, arg) => { next(arg); }, 'test');
queue.push((next) => { next(); }, 'test');
next must be the first parameter; push args come after next.
new CallbackQueue
const queue = new CallbackQueue('initArg');
const queue = new CallbackQueue();
initArgs are optional but if provided, they become first args in every callback.

Demonstrates queue creation, pushing two callbacks with argument passing via push and next.

const CallbackQueue = require('ca11back-queue'); const queue = new CallbackQueue(); queue.push((next, msg) => { console.log('First:', msg); next('world'); }, 'hello'); queue.push((next, msg) => { console.log('Second:', msg); next(); }); // Output: // First: hello // Second: world
Debug
Known issues
gotchaIf next() is not called, the queue will hang and subsequent callbacks never execute.
fix
Ensure every callback invokes next() exactly once.
affects: >=1.0.0
breakingv3 dropped support for Node versions below 14.0.0.
fix
Update Node to >=14.0.0.
affects: >=3.0.0
gotchaThe first callback pushed is invoked immediately; subsequent calls are queued. This may cause unexpected execution order if called asynchronously.
fix
Push all callbacks synchronously to ensure ordering.
affects: >=1.0.0
gotchaArguments passed to push() are static for that callback; arguments from next() override only if provided.
fix
Use next() with explicit arguments to propagate dynamic data.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: next is not a function
Callback does not include next as the first parameter or next is invoked incorrectly.
fix
Define callback as function(next, ...args) { next(); }.
ReferenceError: initArgs is not defined
Trying to access initArgs variable inside callback without having passed them to CallbackQueue constructor.
fix
Instantiate with new CallbackQueue('arg1') and use parameter names in callback.
Error: callback must be a function
push() called with a non-function as the first argument.
fix
Pass a function as the first argument to queue.push().
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
ca11back-queue — npm install ca11back-queue · libregistry