Registry / storage / data-queue

data-queue

JSON →
library0.0.3jsnpmunverified

A lightweight async data queue for Node.js that supports appending, prepending, and error handling. Version 0.0.3 is the latest stable release. It provides a simple callback-based API for buffering data and processing it asynchronously, similar to a stream but without the complexity. Key differentiators: minimal dependencies, no external libraries, and built-in error propagation that prevents further data addition after an error.

npm install data-queue
INSTALL
IMPORT
SIG · DATA-QUEUE
D
data-queue
storagejavascriptv0.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.

Queue
const Queue = require('data-queue')
import Queue from 'data-queue'
This package is CommonJS only; there is no ESM export.
queue instance
const queue = Queue()
const queue = new Queue()
Queue() must be called without new; it is a factory function.
queue.append
queue.append(data)
queue.append(data, callback)
append does not accept a callback; data is passed to the next get().

Shows basic usage: creating a queue, adding data, retrieving data with callbacks, and error handling.

const Queue = require('data-queue') const queue = Queue() // Consumer queue.get((err, data) => { if (err) { console.error(err); return } console.log('Received:', data) }) // Producer queue.append('Hello') queue.append('World') // Check size console.log('Queue height:', queue.height()) // Error propagation queue.error(new Error('Fatal')) // Subsequent appends are ignored queue.append('This will not be added')
Debug
Known issues
gotchaCalling Queue() without new is required. Using new Queue() will throw because the function is not a constructor.
fix
Remove the new keyword: const queue = Queue()
affects: >=0.0.1
gotchaAfter queue.error() is called, all subsequent append/prepend calls are silently ignored. Data may be lost if you expect them to queue.
fix
Check for errors before appending or use a wrapper that tests queue state.
affects: >=0.0.1
gotchaThe get() callback pattern is non-standard: the first argument is error, second is data. It's similar to Node.js callbacks but not identical in error handling behavior.
fix
Always handle the error argument before data.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Using new Queue() instead of Queue()
fix
Remove new: const queue = Queue()
queue.get is not a function
Calling get on a non-existent or invalid queue instance
fix
Ensure queue is created with Queue()
data is undefined or queue.get never returns
No data was appended before get was called and no error occurred
fix
Make sure to call queue.append() or queue.error() to unblock get()
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
32
OpenAI (training)
1
Resources
data-queue — npm install data-queue · libregistry