Registry / devops / throttle-queue

throttle-queue

JSON →
library0.1.0jsnpmunverified

throttle-queue 0.1.0 is a promise-based priority queue for Node.js and browser environments that offers task deduplication, concurrency control, serial execution, and job aging to prevent starvation. It supports async/await patterns and allows setting a custom executor function. Version 0.1.0 is the initial release; the package is no longer actively maintained. Key differentiators: built-in deduplication via job IDs, aging mechanism, and priority levels (low, medium, high).

npm install throttle-queue
INSTALL
IMPORT
SIG · THROTTLE-QUEUE
T
throttle-queue
devopsjavascriptv0.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
const Queue = require('throttle-queue');
import Queue from 'throttle-queue';
The package exports a single class via default CommonJS export. ESM import is not supported.
instance methods: setExecutor, process, clear
const queue = new Queue({ concurrency: 2 }); queue.setExecutor(async (params) => { ... });
Queue.setExecutor(...);
Methods are instance methods, not static. Always create an instance with `new Queue()`.
Queue.priority (constants)
queue.process(params, id, { priority: Queue.priority.HIGH });
queue.process(params, id, { priority: 'high' });
Priority values are numeric constants accessed via `Queue.priority`. They are not strings.

Creates a throttle-queue with concurrency 2, sets an async executor, and processes a deduplicated task with priority.

const Queue = require('throttle-queue'); const taskQueue = new Queue({ concurrency: 2, aging: true }); taskQueue.setExecutor(async ({ pokemon }) => { const url = `https://pokeapi.co/api/v2/pokemon/${pokemon}`; const response = await fetch(url); return await response.json(); }); const result = await taskQueue.process({ pokemon: 'mew' }, 'mew', { priority: Queue.priority.HIGH }); console.log('I found', result);
Debug
Known issues
breakingThe package must be required with CommonJS (`require`) — ESM `import` will fail.
fix
Use `const Queue = require('throttle-queue');`.
affects: >=0.0.0
breakingThe `process` method requires a unique `id` for deduplication. Omitting it or passing duplicate IDs will cause the task to be dropped silently.
fix
Always provide a unique id per distinct task.
affects: >=0.0.0
gotchaPriority options are numeric constants (`Queue.priority.HIGH`, `Queue.priority.MEDIUM`, `Queue.priority.LOW`) and default to 5 (LOW). Using string values will not be recognized and may lead to unexpected behavior.
fix
Use `Queue.priority.HIGH` (value 1), `Queue.priority.MEDIUM` (value 3), or `Queue.priority.LOW` (value 5).
affects: >=0.0.0
gotchaThe executor function must be set with `setExecutor` before any calls to `process`. Calling `process` without an executor will throw an error like "Executor is not defined".
fix
Call `queue.setExecutor(executor)` before `await queue.process(...)`.
affects: >=0.0.0
gotchaThe package is not actively maintained; there may be unresolved issues or security vulnerabilities in its dependencies.
fix
Consider using alternatives like `p-queue` or `bottleneck` for active support.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Trying to import via ESM (`import Queue from 'throttle-queue'`) but the package only supports CommonJS.
fix
Use `const Queue = require('throttle-queue');`
TypeError: queue.setExecutor is not a function
Calling setExecutor on a non-instance (e.g., `Queue.setExecutor(...)` instead of `const queue = new Queue(); queue.setExecutor(...)`)
fix
Create an instance first: `const queue = new Queue();` then call `queue.setExecutor(...)`
Error: Executor is not defined
Calling `queue.process(...)` before setting an executor with `setExecutor`.
fix
Set executor via `queue.setExecutor(executor)` before processing tasks.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
throttle-queue — npm install throttle-queue · libregistry