Registry / devops / grouped-queue

grouped-queue

JSON →
library2.1.0jsnpmunverified

An in-memory priority task queue system that organizes tasks into named groups and processes them in order. Version 2.1.0 is the latest stable release, with an irregular release cadence. It differentiates from other queues (like async.queue or bull) by its grouping mechanism, allowing developers to define an ordered list of group names, where tasks in the first group are fully drained before processing the next group. The package also supports deduplication via the 'once' option, delayed execution without auto-start, and pause/resume. It ships TypeScript type definitions and works with Node.js >=8.0.0.

npm install grouped-queue
INSTALL
IMPORT
SIG · GROUPED-QUEUE
G
grouped-queue
devopsjavascriptv2.1.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.

Queue
import Queue from 'grouped-queue'
const { Queue } = require('grouped-queue')
ESM default import. CommonJS users should use const Queue = require('grouped-queue').default
GroupedQueueOptions
import type { GroupedQueueOptions } from 'grouped-queue'
import { GroupedQueueOptions } from 'grouped-queue'
TypeScript type; must use type import to avoid runtime error.
TaskFunction
import type { TaskFunction } from 'grouped-queue'
Exported type for callback-based task functions.

Creates a queue with two groups (urgent, default), adds tasks, and processes them in priority order.

import Queue from 'grouped-queue'; import { setTimeout } from 'timers/promises'; const queue = new Queue(['urgent', 'default']); queue.on('end', () => { console.log('All tasks completed.'); }); queue.add('urgent', async (cb) => { console.log('Urgent task started'); await setTimeout(100); console.log('Urgent task done'); cb(); }); queue.add((cb) => { console.log('Default task started'); setTimeout(() => { console.log('Default task done'); cb(); }, 200); }); queue.start();
Debug
Known issues
breakingThe constructor changed from accepting a list of group names as rest parameters to a single array in v2.
fix
Use `new Queue(['group1', 'group2'])` instead of `new Queue('group1', 'group2')`.
affects: >=2.0.0
breakingThe default export changed from a function to a class in v2. Requiring the module returns the Queue class directly, not a factory.
fix
Use `const Queue = require('grouped-queue').default` for CommonJS, or import default.
affects: >=2.0.0
deprecatedThe `add` method's callback-based API is not deprecated, but TypeScript users should use async functions with explicit callback call.
fix
Always call the `cb` parameter when using synchronous callbacks, or use async/await pattern.
affects: *
gotchaIf `runOnAdd` is set to `false` in constructor, calling `start()` is required after adding tasks. Forgetting to call `start()` will leave tasks pending forever.
fix
Ensure you call `queue.start()` when using `runOnAdd: false`.
affects: *
gotchaThe 'end' event fires after each group empties, not after all groups are processed. If you only need one final callback, you must track group completions manually.
fix
Listen to 'end' for each group; or implement a counter to detect when all groups finish.
affects: *
Errors
Common errors & fixes
TypeError: queue.add is not a function
Using CommonJS `require('grouped-queue')` without `.default` in v2 (ESM package).
fix
Use `const Queue = require('grouped-queue').default;` or switch to ES modules.
Queue is not a constructor
Importing the module as `import { Queue } from 'grouped-queue'` instead of `import Queue from 'grouped-queue'`.
fix
Use default import: `import Queue from 'grouped-queue'`.
TypeError: cb is not a function
Using async function without calling the callback. The task function must call `cb()` when done.
fix
Ensure you call `cb()` after completing async work: `queue.add(async (cb) => { await doWork(); cb(); })`.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
grouped-queue — npm install grouped-queue · libregistry