Registry / storage / buffer-queue

buffer-queue

JSON →
library1.0.0jsnpmunverified

Buffer queue for Node.js streams that accumulates Buffer chunks and drains them in fixed-size pieces. Version 1.0.0 (stable, last release 2015). Optimized to be faster than repeatedly calling Buffer.concat on each chunk. Provides Store class with push, shift, empty, length, and drain methods. Minimal API, no dependencies. Useful for throttling or batching binary data in streams. No updates since 2015; consider alternatives like bl or native Buffer.concat.

npm install buffer-queue
INSTALL
IMPORT
SIG · BUFFER-QUEUE
B
buffer-queue
storagejavascriptv1.0.0
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.

BufferStore
import BufferStore from 'buffer-queue'
const { BufferStore } = require('buffer-queue')
Package exports a single constructor via module.exports = BufferStore; use default import or require('buffer-queue') directly.
Store
const Store = require('buffer-queue')
const { Store } = require('buffer-queue')
The package is historically used with CommonJS; the exported value is the constructor, not named export. In ESM, use default import and rename as needed.

Shows basic usage: create store, push buffers, shift a fixed number of bytes, check length, drain, and empty.

import Store from 'buffer-queue'; const store = new Store(); // Push buffers store.push(Buffer.from('hello ')); store.push(Buffer.from('world')); // Get first 5 bytes const chunk = store.shift(5); console.log(chunk.toString()); // 'hello' console.log(store.length()); // 5 (remaining 'world') // Drain all remaining const remainder = store.drain(); console.log(remainder.toString()); // 'world' // Alternatively use empty() to discard without returning store.push(Buffer.from('discard')); store.empty(); console.log(store.length()); // 0
Debug
Known issues
deprecatedPackage is in maintenance mode with no updates since 2015. Consider using bl (BufferList) or native Buffer.concat for newer projects.
fix
Switch to bl or use Buffer.concat after collecting chunks.
affects: >=1.0.0
gotchashift(n) returns null if store is empty. Always check return value.
fix
Always check for null: const chunk = store.shift(n); if (chunk) { ... }
affects: *
gotchabuffer-queue is not a duplex stream buffer; it does not implement Node.js stream interface. It is a simple queue store.
fix
Use only as shown in documentation: push, shift, length, drain, empty.
affects: *
Errors
Common errors & fixes
TypeError: store.push is not a function
Importing incorrectly, e.g., using named import { Store } or { BufferStore }
fix
Use default import or require('buffer-queue') directly: const Store = require('buffer-queue'); const store = new Store();
TypeError: store.shift is not a function
Store not instantiated with new, or used as static method.
fix
Ensure you call new Store() before using shift.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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