Registry / devops / queue-system

queue-system

JSON →
library4.1.1jsnpmunverified

A powerful yet simple JavaScript/TypeScript tasks queue system for Node.js and browsers. Current stable version is 4.1.1. It supports concurrency control, pause/unpause, task insertion at any position, forced start, cancellation (including running tasks), and event monitoring. Fully unit tested with full TypeScript support. Differentiated by its clean API and flexible task ordering.

npm install queue-system
INSTALL
IMPORT
SIG · QUEUE-SYSTEM
Q
queue-system
devopsjavascriptv4.1.1
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
✓ import { Queue } from 'queue-system'
✗ const Queue = require('queue-system').Queue
ESM only; default export is not available.
Task
✓ import type { Task } from 'queue-system'
TypeScript type for tasks; not a runtime value.
QueueEvents
✓ import { QueueEvents } from 'queue-system'
✗ import { Events } from 'queue-system'
QueueEvents is the correct event enum name.

Creates a queue with concurrency 2, adds two tasks, starts, pauses, inserts a priority task, and resumes.

import { Queue } from 'queue-system'; const queue = new Queue({ concurrency: 2 }); queue.on('taskComplete', (result) => { console.log('Task completed:', result); }); queue.add(() => new Promise(resolve => setTimeout(() => resolve('First'), 1000))); queue.add(() => new Promise(resolve => setTimeout(() => resolve('Second'), 500))); queue.start(); setTimeout(() => { queue.pause(); console.log('Paused'); // Insert a high-priority task at the front queue.add(() => Promise.resolve('Urgent'), { priority: true }); queue.start(); }, 200);
Debug
Known issues
breakingVersion 3.0.0 changed the API: queue is no longer a function constructor; use new Queue() instead.
fix
Use class instantiation: const queue = new Queue(options);
affects: <3.0.0 || >=3.0.0
breakingEvents API renamed from 'task-complete' to 'taskComplete' in v4.0.0.
fix
Use camelCase event names: queue.on('taskComplete', handler).
affects: >=4.0.0
breakingCancellation behaviour changed in v4.0.0: running tasks are now cancelled by default when destroy() is called.
fix
Use destroy({ cancelRunning: false }) to preserve old behaviour.
affects: >=4.0.0
deprecatedThe option 'forceStart' is deprecated; use 'add' with { force: true } instead.
fix
queue.add(task, { force: true });
affects: >=3.5.0
gotchaConcurrency set to 0 will block all tasks; no tasks will run until concurrency is increased.
fix
Set concurrency to at least 1 if you expect tasks to execute immediately.
affects: *
Errors
Common errors & fixes
Queue is not a constructor
Importing incorrectly in CommonJS or using version <3.0.0 with wrong syntax.
fix
Use import { Queue } from 'queue-system' (ESM) or const { Queue } = require('queue-system') (CommonJS).
Cannot find module 'queue-system'
Package not installed or module resolution misconfigured (e.g., missing .js extension in ESM).
fix
Run npm install queue-system. For ESM, ensure import uses correct path and Node v12+.
task.cancel is not a function
Attempting to cancel a task that has already completed or was not returned from queue.add().
fix
Capture the task object: const task = queue.add(...); then call task.cancel() before it finishes.
Upgrade
Version history
4.1.1latest on npm
Audit
Dependencies
event-emitter-ishrequiredUsed for event handling; bundled dependency but may appear in node_modules.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
queue-system — npm install queue-system · libregistry