Registry / storage / disk-storage

disk-storage

JSON →
library1.3.2jsnpmunverified

disk-storage is a Node.js library for storing large amounts of data efficiently on disk. It provides buffer-based reading with cursor support and parallelism, as well as line and batch line reading. Writing is done via append operations. It is designed for high performance and works on Node.js versions 8 and above. The library is stable at version 1.3.2 and is actively maintained on GitHub. It is a lightweight alternative to more complex storage solutions like LevelDB or RocksDB, focusing on simplicity and efficiency for log-like data.

npm install disk-storage
INSTALL
IMPORT
SIG · DISK-STORAGE
D
disk-storage
storagejavascriptv1.3.2
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.

DiskStorage
✓ import { DiskStorage } from 'disk-storage'
✗ const DiskStorage = require('disk-storage').DiskStorage
ESM import is the preferred method; CommonJS users should use const { DiskStorage } = require('disk-storage').
default
✓ import DiskStorage from 'disk-storage'
✗ import { default as DiskStorage } from 'disk-storage'
The library also exports a default export, which is equivalent to the named export DiskStorage.
DiskStorage
✓ const { DiskStorage } = require('disk-storage')
✗ const DiskStorage = require('disk-storage')
CommonJS users must destructure the named export; the default export is not available via require.

This example shows how to create a DiskStorage instance, append data, and read lines using an async iterator.

import { DiskStorage } from 'disk-storage'; const storage = new DiskStorage({ directory: './data', maxFileSize: 1024 * 1024 * 10, // 10 MB }); async function main() { // Append data await storage.append('Hello, world!\n'); await storage.append('Another line\n'); // Read lines const reader = storage.createReader(); for await (const line of reader) { console.log(line); } // Close storage await storage.close(); } main().catch(console.error);
Debug
Known issues
gotchaThe directory for storage will be created if it does not exist, but ensure the parent directory is writable.
fix
Check permissions of the parent directory before creating the storage.
affects: >=1.0
deprecatedThe `maxFileSize` option may be deprecated in future versions in favor of a more dynamic limit.
fix
Use the current option but monitor releases for changes.
affects: 1.x
gotchaReading with a cursor requires manual management of the cursor position; resetting the cursor may not be supported.
fix
Keep track of the cursor externally if you need to restart reading.
affects: >=1.0
breakingNode.js 8 is the minimum supported version; earlier versions will result in errors.
fix
Upgrade to Node.js 8 or later.
affects: >=1.0
Errors
Common errors & fixes
TypeError: storage.append is not a function
Using an outdated version of the library or incorrect import.
fix
Ensure you have the latest version installed: npm install disk-storage@latest and use correct import.
Error: EACCES: permission denied, open './data/file.log'
Insufficient permissions to create or write to the storage directory.
fix
Run the process with appropriate permissions or change the directory to a writable location.
SyntaxError: Unexpected token 'export'
Using ESM syntax in a CommonJS environment without transpilation.
fix
Use CommonJS require: const { DiskStorage } = require('disk-storage'); or set up a transpiler.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
disk-storage — npm install disk-storage · libregistry