Registry / storage / hypercore-default-storage

hypercore-default-storage

JSON →
library1.1.1jsnpmunverified

Default storage provider for Hypercore, using random-access-file for persistent storage of hypercore feeds. Version 1.1.1 is the latest stable release. This package provides a simple storage factory function that creates random-access-storage instances for Hypercore, handling file locking for bitfield files to prevent parallel writers. It is a small, focused utility specific to the Hypercore ecosystem, commonly used in Hypercore-based applications like Dat-Protocol archives. Release cadence is low as it is a stable dependency.

storage
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.

This package is CommonJS only. ESM import is not supported; you must use require().

const defaultStorage = require('hypercore-default-storage')

Shows how to create a Hypercore feed with defaultStorage as the storage provider, append data, and read it back.

const defaultStorage = require('hypercore-default-storage') const hypercore = require('hypercore') const storage = name => defaultStorage(name, { directory: './my-data' }) const feed = hypercore(storage) feed.append(Buffer.from('Hello, world!'), (err) => { if (err) throw err feed.get(0, (err, data) => { console.log(data.toString()) // 'Hello, world!' }) })
Debug
Known footguns
gotchaThe storage function must return a random-access-storage instance, not a promise or other type.
gotchaIf directory option is not provided, it defaults to current working directory, which may lead to unintended file pollution.
gotchaBitfield files are locked to avoid parallel writers; do not attempt to share storage paths across processes.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
18 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
3
bingbot
1
ahrefsbot
1
Resources