Base class for implementing random-access-storage abstractions in Node.js. Current stable version is 3.0.2. Provides a common interface for storage backends with read/write/del operations, managing open/close lifecycle, flow control, and error handling. Unlike directly using fs or streaming abstractions, it enforces a consistent contract for random-access patterns and handles automatic opening, suspension, and cleanup. Useful for building custom storage drivers (file, memory, network) that comply with the Hypercore ecosystem. Maintained actively with frequent releases.
npm install random-access-storageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a file-backed RandomAccessStorage with open/read/close lifecycle, reads first 10 bytes, logs result, then closes.
Migrate listeners from storage.on('ready') to storage.on('open') or use storage.opened property.Update callback handlers to accept (err, result) only.
Ensure req.callback is called exactly once per operation.
Use 'createAlways: true' in options instead of 'create: true'.
Implement at least one of _read or _write before using the storage.
No fix needed, but be aware that automatic open may cause order-of-operations issues if you rely on synchronous setup.
Use const RandomAccessStorage = require('random-access-storage') (no destructuring).Call req.callback(null, Buffer.alloc(req.size)) or ensure buffer length matches req.size.
Use regular functions or bind correctly: open: function (req) { ... }Check storage.closed before operations, or ensure close only after all operations.
No dependency data recorded yet.