Registry / testing / callq
library1.0.7jsnpmunverified

callq is a lightweight, zero-dependency async call queue library for Node.js that provides a state machine-like execution of ordered asynchronous operations with support for branch, jump, sub-procedures, loops, forks, and timeouts. Current version 1.0.7 (maintained as of 2023). It differentiates itself by offering a flexible queue structure with sync/async operators, label-based routing, and procedural control flows (if, loop, fork, join) while remaining simple and small. The library uses an error-data-queue callback convention and supports both synchronous returns and asynchronous callbacks via que.next() or que.wait().

npm install callq
INSTALL
IMPORT
SIG · CALLQ
C
callq
testingjavascriptv1.0.7
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.

default (main module)
✓ const cq = require('callq');
✗ import cq from 'callq';
callq is CommonJS only; ESM import is not supported natively.
CallQueue class
✓ const CallQueue = require('callq').CallQueue;
✗ import { CallQueue } from 'callq';
If available as named export; check docs. CommonJS destructuring works.
type definitions (if any)
✓ // No TypeScript types provided by the package.
✗ types are not shipped.
callq does not include TypeScript declarations; use @types/callq if available or define your own.

This example shows how to create a queue with named operators, use que.jump to redirect execution flow, and define both synchronous and asynchronous operators.

var cq = require('callq'); var myObj = { f1: function (error, data, que) { console.log(data = "1-label"); setTimeout(function() { que.jump(null, data, "f3"); }, 50); }, f2: function (error, data, que) { console.log(data = data + ",2-end"); setTimeout(function() { que.jump(null, data, "f4"); }, 50); }, f3: function (error, data, que) { console.log(data = data + ",3-label"); setTimeout(function() { que.jump(null, data, "f2"); }, 50); }, f4: function (error, data, que) { var expect = "1-label,3-label,2-end"; if(data != expect) throw Error("expect (" + expect + ") but (" + data + ")"); que.next(null, data); }, }; cq(myObj, ["f1", "f2", "f3", "f4"]);
Debug
Known issues
gotchaThe package uses CommonJS only; ESM import may fail or require dynamic import().
fix
Use require('callq') or wrap with createRequire in ESM.
affects: >=1.0.0
gotchaOperators must return undefined if they call que.next() asynchronously; otherwise the return value may be treated as data.
fix
Ensure async operators return undefined and call que.next() inside the callback.
affects: >=1.0.0
gotchaLabel strings prefixed with ':' are treated as sub-procedures and skipped during normal processing; they must be explicitly picked via .pick().
fix
Use .pick(':label') to invoke a sub-procedure.
affects: >=1.0.0
breakingNo major breaking changes documented; the API has remained stable since initial release.
fix
N/A
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: cq is not a function
Improper import: import cq from 'callq' in ESM. The package is CommonJS and exports a function directly.
fix
Use const cq = require('callq'); in CommonJS, or use dynamic import() in ESM: const cq = (await import('callq')).default;
Error: expect (1-label,3-label,2-end) but (1-label,2-end)
Operator f2 was called before f3 due to missing jump or incorrect flow. The example uses que.jump to reorder execution.
fix
Ensure you use que.jump or que.next appropriately to control the order of operations.
que.next is not a function
Using que outside of an operator callback or misnaming the parameter. The 'que' parameter is only available inside operator functions.
fix
Only call que.next() within an operator callback and ensure the parameter name matches.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
packagecallq ↗
callq — npm install callq · libregistry