Registry / devops / timequeue

timequeue

JSON →
library4.0.0jsnpmunverified

A queue with custom concurrency and time limits, inspired by async/queue but with variable arguments in the worker, events, and optional time limits. Version 4.0.0 is current, ships TypeScript types, requires Node >=10. Differentiators include support for async workers, per-task timeout, rate limiting (every option), and custom store backends (e.g., Redis). Maintained with regular releases.

npm install timequeue
INSTALL
IMPORT
SIG · TIMEQUEUE
T
timequeue
devopsjavascriptv4.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.

TimeQueue
import TimeQueue from 'timequeue'
const { TimeQueue } = require('timequeue')
Default export. CommonJS require works: const TimeQueue = require('timequeue'). ESM import is the default import.
MemoryStore
import MemoryStore from 'timequeue/src/mem-store'
require('timequeue').MemoryStore
MemoryStore is not exported from the main entry; it's a separate file. Not typically imported directly.
TypeScript types
import type TimeQueue from 'timequeue'
Types are included; use import type for type-only usage.

Creates a TimeQueue with an async worker, pushes two tasks, and logs results.

import TimeQueue from 'timequeue'; const worker = async (task: string): Promise<string> => { // simulate async work return new Promise(resolve => setTimeout(() => resolve(task.toUpperCase()), 100)); }; const queue = new TimeQueue(worker, { concurrency: 2, every: 1000 }); async function main() { const result1 = await queue.push('hello'); console.log(result1); // 'HELLO' const result2 = await queue.push('world'); console.log(result2); // 'WORLD' console.log(queue.active); // 0 console.log(queue.finished); // 2 } main().catch(console.error);
Debug
Known issues
gotchaIf queue is full (maxQueued limit reached), push() will silently ignore the task and may not call the callback.
fix
Check queue.isFull() before pushing, or set maxQueued to a high value.
affects: >=4.0.0
gotchaThe worker function's last argument is a callback for synchronous workers. For async workers, do not use a callback; return a promise instead.
fix
Ensure async workers return a promise and do not accept a callback parameter.
affects: >=4.0.0
gotchaThe 'every' option delays task start even after a task finishes; 'active' updates immediately but 'intransit' reflects delayed states.
fix
Use 'active' for immediate count; use 'intransit' for rate-limited queue logic.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: worker is not a function
TimeQueue constructor expects a function as first argument
fix
Ensure the first argument to new TimeQueue() is a function (async or sync with callback).
TimeoutError: task timed out
The task exceeded the timeout option set on the queue
fix
Increase timeout or optimize worker to complete faster.
Cannot find module 'timequeue'
Package not installed
fix
Run 'npm install timequeue' in your project.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
timequeue — npm install timequeue · libregistry