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.

devops
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.

This package is CommonJS only and does not support ESM import syntax.

const queue = require('block-queue');

queue is a factory function, not a constructor. Do not use 'new'.

const q = queue(1, reducer);

push only accepts a single task argument. No callback or options.

q.push('task');

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 footguns
gotchaThe 'blocking' behavior: queue.push will block if all slots are occupied. This can cause deadlocks if the reducer never calls done.
deprecatedPackage has not been updated since 2013 and may have compatibility issues with modern Node.js versions.
gotchaNo support for error handling: errors thrown in the reducer are not caught.
gotchaqueue.clear() does not cancel in-flight tasks; it only empties pending tasks.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
mj12bot
1
Resources