Registry / storage / buffered-queue

buffered-queue

JSON →
library1.0.1jsnpmunverified

A simple, zero-dependency Node.js module that buffers items (objects, strings, numbers) until a maximum size is reached or a flush interval expires. Current stable version is 1.0.1. It is a small, flexible utility for batching operations with a configurable custom result function. Unlike more complex message queues, buffered-queue focuses on a minimal API with events and basic options, suitable for lightweight in-process buffering. Updates are infrequent, but the module is stable and has no known issues. It is primarily used in Node.js environments and does not support ESM natively, relying on CommonJS require().

npm install buffered-queue
INSTALL
IMPORT
SIG · BUFFERED-QUEUE
B
buffered-queue
storagejavascriptv1.0.1
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.

Queue
✓ const Queue = require('buffered-queue');
✗ import Queue from 'buffered-queue';
Package does not export ESM; use CommonJS require().
Queue
✓ const { default: Queue } = require('buffered-queue');
✗ const Queue = require('buffered-queue').Queue;
The export is the constructor itself, not a named property.

Creates a buffered queue with size 3 and 5s timeout, adds three items, and logs the flush event with processed data.

const Queue = require('buffered-queue'); const q = new Queue('myqueue', { size: 3, flushTimeout: 5000, verbose: true, customResultFunction: function(items) { return items.join(', '); } }); q.on('flush', function(data, name) { console.log('Flush:', data, 'from', name); }); q.add('item1'); q.add('item2'); q.add('item3');
Debug
Known issues
gotchaQueue constructor expects two arguments: name (string) and options (object). Passing only options as first argument will cause a TypeError.
fix
Always provide a name string as first argument, even if empty: new Queue('', {...})
affects: >=1.0.0
gotchacustomResultFunction if provided must return an array-like or the data passed to the flush event will be undefined or malformed.
fix
Ensure customResultFunction returns an array (or the desired data structure).
affects: >=1.0.0
gotchaThe 'flush' event callback receives data and name, but if customResultFunction returns a non-array, data may be inconsistent with typical usage.
fix
Review customResultFunction output to match expected format for flush event handling.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Using ESM import syntax with a CommonJS-only module.
fix
Use require('buffered-queue') instead of import.
TypeError: Cannot read properties of undefined (reading 'on')
Calling q.on() before creating a queue (e.g., on an undefined variable).
fix
Ensure the Queue constructor is called with new and the returned object is assigned.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
36
OpenAI (training)
1
Resources
buffered-queue — npm install buffered-queue · libregistry