Registry / devops / run-queue

run-queue

JSON →
library2.0.1jsnpmunverified

A promise-based, dynamic priority queue runner with concurrency limiting for Node.js. Version 2.0.1 is stable but receives only sporadic maintenance. It allows adding jobs with integer priorities, ensures that all jobs of a lower priority complete before higher priorities execute, and dynamically switches back to lower priorities if new jobs are added. Supports configurable concurrency (default 1) and custom Promise implementations. Lightweight with no runtime dependencies.

devops
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.

Package is CJS-only; no ESM exports.

const RunQueue = require('run-queue')

Default import only; no named exports.

import pkg from 'run-queue'; const RunQueue = pkg; // or const { RunQueue } = require('run-queue')

RunQueue is a class, not a factory function.

const { add, run } = require('run-queue'); // No, RunQueue is a class

Creates a queue with concurrency 2, adds jobs at priorities 0 and 1, runs them, and logs completion.

const RunQueue = require('run-queue'); const queue = new RunQueue({ maxConcurrency: 2, Promise: require('bluebird') // optional custom Promise }); let completed = 0; const log = (id) => new Promise((resolve) => { setTimeout(() => { completed++; console.log(`Job ${id} done (${completed})`); resolve(); }, 100); }); queue.add(0, log, ['A']); queue.add(1, log, ['B']); // B waits for A queue.add(0, log, ['C']); // C runs before B queue.run().then(() => { console.log('All done'); }).catch(err => { console.error('Queue failed:', err); });
Debug
Known footguns
gotchaPriority behavior: All jobs of a lower priority must finish before any jobs of a higher priority start. Adding new lower-priority jobs during higher-priority execution will cause the queue to switch back to lower priority, delaying higher-priority jobs.
gotchamaxConcurrency: 1 is default. If you expect concurrent execution, you must explicitly set maxConcurrency > 1.
deprecatedThe callback-style `fn(args, next)` pattern is supported but deprecated. Use async functions returning Promises instead.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
7 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources