Registry / devops / can-queues

can-queues

JSON →
library1.3.2jsnpmunverified

A lightweight JavaScript task queue library (v1.3.2) for managing asynchronous task execution with priority and batching. Part of the CanJS ecosystem, it provides simple queue APIs for deferring and ordering callbacks, with support for dynamic priority and concurrency control. Stable, infrequent releases, suitable for applications needing structured task scheduling without heavy dependencies. Differentiated by its minimal footprint and integration with CanJS observables.

npm install can-queues
INSTALL
IMPORT
SIG · CAN-QUEUES
C
can-queues
devopsjavascriptv1.3.2
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
import queues from 'can-queues'
const queues = require('can-queues')
This package is ESM-only since v1.0. CommonJS require will fail unless using a bundler that supports ESM.
enqueue
import { enqueue } from 'can-queues'
import { enqueue } from 'can-queues/dist/queues.js'
Named exports are available directly from the package root. Avoid deep import paths which may break.
Queue
import { Queue } from 'can-queues'
Queue is a constructor for creating custom queue instances. TypeScript types are included.

Shows importing the default export, enqueuing tasks with and without priority, and creating a custom queue instance.

import queues from 'can-queues'; const task = () => console.log('Task executed'); queues.enqueue(task); // With priority const highPriorityTask = () => console.log('High priority'); queues.enqueue(highPriorityTask, { priority: 10 }); // Create a named queue const myQueue = new queues.Queue(); myQueue.enqueue(() => console.log('In custom queue')); myQueue.run();
Debug
Known issues
gotchaDefault import does not include named exports like enqueue or Queue. Use named import syntax for those.
fix
Use import { enqueue, Queue } from 'can-queues' if you need specific members.
affects: >=1.0
gotchaThe enqueue function returns a promise that resolves when the task completes. Forgetting to await may cause unhandled rejections.
fix
await queues.enqueue(task) or attach .catch() to the returned promise.
affects: >=1.0
gotchaCustom queues created with new Queue() do not auto-run; you must call run() manually. This differs from the default queue behavior.
fix
Call queue.run() after enqueuing tasks to execute them.
affects: >=1.0
deprecatedThe method 'dequeue' is deprecated since v1.2. Use 'remove' instead.
fix
Replace queue.dequeue(task) with queue.remove(task).
affects: >=1.2
Errors
Common errors & fixes
TypeError: queues.enqueue is not a function
Default import does not include enqueue as a property; it returns an object with multiple methods.
fix
Use import queues from 'can-queues' then call queues.enqueue, or import { enqueue } directly.
ReferenceError: require is not defined
The package is ESM-only and does not support CommonJS require.
fix
Use import statements instead of require().
RangeError: Maximum call stack size exceeded
Infinitely recursive tasks without proper guards.
fix
Ensure tasks do not re-enqueue themselves indefinitely or use a depth limit.
Error: Task queue is full
Attempted to enqueue when the queue size limit (default 1024) is exceeded.
fix
Increase max size via options: new Queue({ maxSize: 2048 }) or remove completed tasks.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
can-queues — npm install can-queues · libregistry