Registry / storage / disk-queue

disk-queue

JSON →
library0.1.3jsnpmunverified

A lightweight queue that persists items to the filesystem to save memory. Version 0.1.3. It uses a file as a buffer, writing and reading items sequentially. It provides basic push, shift, reset, and close operations with drain and reset events. It includes TypeScript definitions and supports custom serializers and deserializers. The package is intended for scenarios where memory needs to be conserved but persistence is not critical.

npm install disk-queue
INSTALL
IMPORT
SIG · DISK-QUEUE
D
disk-queue
storagejavascriptv0.1.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.

DiskQueue
✓ import { DiskQueue } from 'disk-queue'
✗ const DiskQueue = require('disk-queue')
ESM-only package; CommonJS require will fail. Use dynamic import if needed.

Creates a disk-persisted queue, pushes an item, shifts it out, and listens for drain event.

import { DiskQueue } from 'disk-queue'; import { tmpdir } from 'os'; import { join } from 'path'; const filePath = join(tmpdir(), 'test-queue.db'); const queue = new DiskQueue({ filePath }); queue.push({ task: 'example' }); console.log(queue.remainCount); // 1 const item = queue.shift(); console.log(item); // { task: 'example' } console.log(queue.remainCount); // 0 queue.on('drain', () => { console.log('Queue is empty'); }); queue.close();
Debug
Known issues
gotchaPushing after close() throws an error about invalid file descriptor.
fix
Ensure no push() calls after close() or re-instantiate the queue.
affects: >=0.1.0
gotchashift() returns undefined when queue is empty, similar to Arrays. Not a breaking change but often misunderstood.
fix
Check remainCount before calling shift() if undefined is a concern.
affects: >=0.1.0
gotchaThe queue file is not automatically deleted; manual cleanup required.
fix
Call queue.reset() or delete the file manually after usage.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'disk-queue' or its corresponding type declarations.
Package is ESM-only but project uses CommonJS or missing tsconfig settings.
fix
Use 'import' syntax and ensure 'type': 'module' in package.json or install esm package. For TypeScript, add 'moduleResolution': 'node' or 'bundler'.
Error: EMFILE: too many open files
Multiple queue instances or not calling close() after usage.
fix
Ensure queue.close() is called for each instance when no longer needed.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
disk-queue — npm install disk-queue · libregistry