Registry / testing / queue-maplimit

queue-maplimit

JSON →
library0.0.3jsnpmunverified

A lightweight concurrency-limited async queue based on Promises, implementing a mapLimit pattern similar to async.mapLimit. Version 0.0.3 provides a simple API to control the maximum number of concurrent async operations. It is dependency-free and designed for node.js and browser environments where Promise-based concurrency control is needed. Compared to alternatives like p-limit or async.queue, it offers a minimal API surface with a single QueueMapLimit class that takes a limit and an add method accepting an array and iteratee.

npm install queue-maplimit
INSTALL
IMPORT
SIG · QUEUE-MAPLIMIT
Q
queue-maplimit
testingjavascriptv0.0.3
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.

QueueMapLimit
const QueueMapLimit = require('queue-maplimit')
import QueueMapLimit from 'queue-maplimit'
Package uses CommonJS. No ES module version provided.
QueueMapLimit (default import in ESM)
import QueueMapLimit from 'queue-maplimit'
import { QueueMapLimit } from 'queue-maplimit'
In ESM, default import works if using bundler that interops with CJS. Named import fails.
QueueMapLimit (type import in TypeScript)
import QueueMapLimit from 'queue-maplimit'; typeof QueueMapLimit
import { QueueMapLimit } from 'queue-maplimit'
No TypeScript types provided. TypeScript will infer types from JS.

Creates a queue with concurrency limit 2, processes an array with an async iteratee doubling each value, and logs results.

const QueueMapLimit = require('queue-maplimit'); const queue = new QueueMapLimit(2); const arr = [1, 2, 3, 4, 5]; const iteratee = value => new Promise((resolve, reject) => { setTimeout(() => resolve(value * 2), 100); }); queue.add(arr, iteratee).then(result => { console.log('Results:', result); // [2, 4, 6, 8, 10] });
Debug
Known issues
gotchaadd() returns a Promise that resolves with the results array, but if any iteratee rejects, the Promise rejects immediately (no error handling per item).
fix
Handle rejection in .catch() or wrap iteratee to never reject.
affects: <=0.0.3
gotchaThe constructor expects a single number argument (limit). Passing non-number or missing argument throws undefined behavior.
fix
Ensure limit is a positive integer: new QueueMapLimit(5).
affects: <=0.0.3
gotchaarr must be an array; passing other iterables (e.g., Set, generator) will fail silently.
fix
Convert to array first: queue.add([...iterable], iteratee).
affects: <=0.0.3
Errors
Common errors & fixes
TypeError: queue.add is not a function
Importing the package incorrectly, e.g., import { QueueMapLimit } instead of default import in CJS.
fix
Use const QueueMapLimit = require('queue-maplimit') or import QueueMapLimit from 'queue-maplimit'.
UnhandledPromiseRejectionWarning: undefined
QueueMapLimit's add() rejects with undefined when iteratee rejects, leading to unhandled rejection if not caught.
fix
Add .catch() to the add() promise or ensure iteratee never throws.
Cannot read property 'add' of undefined
Forgetting to call new QueueMapLimit(limit) before using queue.add.
fix
Instantiate the queue: const queue = new QueueMapLimit(5);
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
queue-maplimit — npm install queue-maplimit · libregistry