Registry / devops / queue-promised

queue-promised

JSON →
library0.0.30jsnpmunverified

A Node.js library for rate-limiting asynchronous function executions using a queue of worker functions. Each task returns a Promise that resolves when a worker becomes available. Version 0.0.30 is the latest stable release; the library is mature with low release cadence (last update 2019). It offers both a simple wrapper for existing functions and a lower-level API with explicit queue and worker management. Unlike more opinionated rate limiters, it does not enforce any concurrency model beyond a configurable number of workers.

npm install queue-promised
INSTALL
IMPORT
SIG · QUEUE-PROMISED
Q
queue-promised
devopsjavascriptv0.0.30
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.

queuePromised
✓ const queuePromised = require('queue-promised')
✗ import queuePromised from 'queue-promised'
This package does not ship TypeScript types and is CommonJS only. Using ESM import will fail in most environments.
wrapper
✓ const { wrapper } = require('queue-promised')
✗ const wrapper = require('queue-promised/wrapper')
The wrapper function is exported directly on the package, not as a separate module.
queue
✓ const { queue } = require('queue-promised')
✗ import { queue } from 'queue-promised'
CommonJS destructuring works, but ES2015 named imports are not supported.

Shows how to wrap a function with a concurrency limit of 5 workers, then execute multiple tasks. Each call returns a Promise that resolves when a worker is free.

const { wrapper } = require('queue-promised'); const limitedFunction = wrapper((time) => { return new Promise(resolve => { setTimeout(() => resolve(time), time); }); }, 5); // max 5 concurrent workers const times = [100, 200, 300, 400, 500]; const promises = times.map(time => limitedFunction(time)); Promise.all(promises).then(console.log).catch(console.error);
Debug
Known issues
gotchaThe library does not handle uncaught rejections from worker functions; if a worker rejects, the queue silently swallows the error unless you attach .catch to each task promise.
fix
Always attach .catch to every queue.push() or wrapper() call.
affects: >=0.0.0
deprecatedThe worker() function returns a boolean indicating success, but its behavior is inconsistent when the queue is full. This low-level API is not recommended for new code.
fix
Prefer using the wrapper() API which is more reliable.
affects: >=0.0.1
gotchaWorker functions must return a Promise or a value; returning undefined results in a pending promise that never resolves.
fix
Ensure every worker function returns a Promise or a non-undefined value.
affects: >=0.0.0
gotchaThe library uses an in-memory queue; tasks are lost if the process crashes or restarts. No persistence or retry logic.
fix
Implement your own persistence if needed, or use a database-backed queue.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue_promised_1.default.wrapper is not a function
Using ES2015 import on a CommonJS-only package.
fix
Use require() instead: const { wrapper } = require('queue-promised');
Error: Cannot find module 'queue-promised'
Package not installed or not in node_modules.
fix
Run npm install queue-promised or yarn add queue-promised.
Promise { <pending> } console logged instead of resolved value
Forgetting to await or attach .then to the wrapper call.
fix
Use limitedFunction(time).then(data => console.log(data))
Upgrade
Version history
0.0.30latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
queue-promised — npm install queue-promised · libregistry