Registry / devops / yqueue

yqueue

JSON →
library1.0.1jsnpmunverified

YQueue is a concurrent priority task queue for Node.js (v1.0.1, ~monthly releases). It provides concurrency control, prioritized tasks, and error handling for batch operations. Unlike p-limit or bottleneck, YQueue offers both a simple queue and a batch mode with backpressure via `maxQueueLength`. Supports async hooks and best-effort error stack traces. Ships TypeScript types. Lightweight with zero runtime dependencies.

npm install yqueue
INSTALL
IMPORT
SIG · YQUEUE
Y
yqueue
devopsjavascriptv1.0.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.

YQueue
import { YQueue } from 'yqueue'
import YQueue from 'yqueue'
YQueue is a named export, not default. Both ESM and CJS work via named export.
YBatch
import { YBatch } from 'yqueue'
const YBatch = require('yqueue').YBatch
Correct in both ESM and CJS; CommonJS require('yqueue') works but is not the recommended ESM pattern.
YBatchErrors
import { YBatchErrors } from 'yqueue'
Exported class for batch error handling, rarely used directly.

Basic usage of YQueue with priority and YBatch with backpressure.

import { YQueue, YBatch } from 'yqueue'; // Queue example const queue = new YQueue({ concurrency: 2 }); queue.run(async () => { const result = await fetch('https://api.example.com'); return result.json(); }, { priority: 1 }).then(data => console.log(data)); // Batch example const batch = new YBatch({ concurrency: 3, maxQueueLength: 5 }); for (let i = 0; i < 10; i++) { batch.add(async () => { await new Promise(resolve => setTimeout(resolve, 100)); return i; }); } batch.failFast().then(() => console.log('All done'));
Debug
Known issues
gotchaUnhandled promise rejection: tasks added via .run() that throw must be caught; otherwise the error may be unhandled and crash the process.
fix
Always add .catch() to the promise returned by .run(), or use .add() with error handling.
affects: >=1.0.0
gotchaonQueueSizeLessThan does not account for currently running jobs (up to concurrency). It only waits for pending queue size.
fix
If you need to limit total in-flight + pending, implement your own logic or use YBatch with maxQueueLength.
affects: >=1.0.0
deprecatedOptions object for .run() and .add() currently supports only 'priority'. Future versions might add more options; always use object syntax.
fix
No immediate action needed. Use { priority: number } as shown in docs.
affects: >=1.0.0
gotchaYBatch.add() returns a promise that settles when the task is added (queue size < maxQueueLength), not when the task completes.
fix
Wait for .failFast() or .allSettled() to know when tasks finish.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: YQueue is not a constructor
Default import instead of named import.
fix
Use `import { YQueue } from 'yqueue'` instead of `import YQueue from 'yqueue'`.
UnhandledPromiseRejectionWarning: Error: task failed
.run() promise not caught or .add() with no error handling.
fix
Add .catch() to the promise returned by .run() or handle errors via YBatch.failFast().
Error: options.concurrency must be a number >= 1
Passed invalid concurrency value (e.g., 0 or string).
fix
Set concurrency to an integer >= 1.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
Resources
packageyqueue
yqueue — npm install yqueue · libregistry