Registry / devops / block-queue

block-queue

JSON →
library0.0.2jsnpmunverified

A minimal Node.js in-process blocking FIFO queue implementation. Version 0.0.2 is the latest stable release. Provides a simple concurrency-limited task queue with a reducer pattern. Unlike async.queue, this library blocks on push when the internal buffer is full, enforcing backpressure. Suitable for simple in-process task orchestration where flow control is needed.

npm install block-queue
INSTALL
IMPORT
SIG · BLOCK-QUEUE
B
block-queue
devopsjavascriptv0.0.2
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.

default
const queue = require('block-queue');
import queue from 'block-queue';
This package is CommonJS only and does not support ESM import syntax.
queue
const q = queue(1, reducer);
const q = new queue(1, reducer);
queue is a factory function, not a constructor. Do not use 'new'.
queue.push
q.push('task');
q.push('task', callback);
push only accepts a single task argument. No callback or options.

Creates a blocking queue with concurrency 2, pushes three tasks. The reducer processes tasks sequentially per slot.

const queue = require('block-queue'); const q = queue(2, (task, done) => { console.log('Processing:', task); setTimeout(done, 1000); }); q.push('task1'); q.push('task2'); q.push('task3'); // output after ~2 seconds: // Processing: task1 // Processing: task2 // Processing: task3
Debug
Known issues
gotchaThe 'blocking' behavior: queue.push will block if all slots are occupied. This can cause deadlocks if the reducer never calls done.
fix
Ensure the reducer always calls the done callback, even on error.
affects: >=0.0.1
deprecatedPackage has not been updated since 2013 and may have compatibility issues with modern Node.js versions.
fix
Consider using more modern libraries like async.queue or p-limit with promise support.
affects: >=0.0.1
gotchaNo support for error handling: errors thrown in the reducer are not caught.
fix
Wrap reducer body in try-catch and handle errors manually.
affects: >=0.0.1
gotchaqueue.clear() does not cancel in-flight tasks; it only empties pending tasks.
fix
Be aware that currently executing tasks will continue.
affects: >=0.0.1
Errors
Common errors & fixes
Error: done is not a function
Reducer expects a function but something else was passed.
fix
Pass a proper function: function(task, done) { ... }
TypeError: queue is not a constructor
Using 'new' on the queue factory function.
fix
Use queue() without new: const q = queue(1, reducer);
block-queue: task is undefined
Push called without arguments.
fix
Provide a task: q.push('myTask');
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

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