Registry / devops / queue-batch

queue-batch

JSON →
library1.0.3jsnpmunverified

A minimalistic queue processor that emits events. Version 1.0.3 provides a simple batch-processing queue with configurable concurrency and an event-driven API (empty, error events). Key differentiators: lightweight, no dependencies, straightforward callback-based processing. Suitable for rate-limited or sequential task execution. Compare to async.queue or bull for simpler use cases. Low release cadence; last update unknown.

npm install queue-batch
INSTALL
IMPORT
SIG · QUEUE-BATCH
Q
queue-batch
devopsjavascriptv1.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.

Processor
const Processor = require('queue-batch');
import Processor from 'queue-batch';
Library does not provide ES modules; use CommonJS require.
new Processor(callback, concurrency, queue)
const p = new Processor(callback);
const p = Processor(callback);
Processor must be instantiated with new.
p.push(item1, item2, ...)
p.push('a', 'b');
p.push(['a', 'b']);
push expects variadic arguments, not an array. Use concat for arrays.
p.concat(array)
p.concat([1,2,3]);
p.concat(1,2,3);
concat expects a single array argument.

Creates a processor with concurrency 5, pushes tasks, and handles empty/error events.

const Processor = require('queue-batch'); const processor = new Processor((item, next) => { console.log('Processing:', item); setTimeout(next, 100); }, 5); processor.on('empty', () => console.log('Done')); processor.on('error', err => console.error(err)); processor.push('task1', 'task2'); processor.concat(['task3', 'task4']);
Debug
Known issues
gotchapush() accepts variadic arguments, not an array. Passing an array will enqueue the array as a single item.
fix
Use concat(array) to enqueue multiple items from an array.
affects: >=1.0.0
gotchaProcessor does not implement pause/resume. Once items are pushed, they are processed immediately until concurrency limit.
fix
To stop processing, manage external flags in the callback.
affects: >=1.0.0
gotchaError event is not emitted if the callback throws synchronously. Only errors passed to next() are caught.
fix
Wrap callback body in try/catch and call next(error) on exception.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Processor is not a constructor
Missing new keyword or incorrect import
fix
Use `const Processor = require('queue-batch'); new Processor(callback);`
Unhandled 'error' event
Processor emitted 'error' event but no listener attached
fix
Attach an error listener: processor.on('error', (err) => console.error(err));
queue is not iterable
Passing a non-array as queue option to constructor
fix
Provide an array as third argument or omit it: new Processor(callback, 10, [])
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

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