{"name":"hypercore-storage","version":"1.9.5","main":"index.js","scripts":{"test":"standard && node test/all.js","test:bare":"bare test/all.js","test:generate":"brittle -r test/all.js test/*.js"},"author":{"name":"Holepunch Inc."},"license":"Apache-2.0","description":"Storage engine for Hypercore","imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"dependencies":{"b4a":"^1.6.7","bare-fs":"^4.0.1","bare-path":"^3.0.0","compact-encoding":"^2.16.0","device-file":"^1.2.2","flat-tree":"^1.12.1","hypercore-crypto":"^3.4.2","hyperschema":"^1.7.0","index-encoder":"^3.3.2","resolve-reject-promise":"^1.0.0","rocksdb-native":"^3.1.1","scope-lock":"^1.2.4","streamx":"^2.21.1"},"devDependencies":{"brittle":"^3.7.0","standard":"^17.1.2","test-tmp":"^1.3.1"},"_id":"hypercore-storage@1.9.5","gitHead":"8c584b7786b7ac81a80ccf6c5865e40e25a4e67e","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-wce9e2UjTizjb8otO7Pp8QEq2oI0KhNnTCCk0dgIJ+hu1qZ5j2EfJCvI8iWMhZRYlzGd+FwkH8ZYr/7/GdOW3w==","shasum":"5b9f1dd967bd5caed837acda9a4b12654037ce26","tarball":"http://registry-npm.ywwl.com/hypercore-storage/download/hypercore-storage-1.9.5.tgz","fileCount":13,"unpackedSize":127915,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFEWVmr0T0v3FmjN/XyOyHaQ3LnNr83CJo1wmUHIc8NIAiEAgYpqOTxfSGlWETpQsDs7NxKqZqieiuxjYlFWjfLJOn4="}],"size":26754,"noattachment":false,"key":"/hypercore-storage/-/hypercore-storage-1.9.5.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hypercore-storage_1.9.5_1742562808845_0.5497714064434018"},"_hasShrinkwrap":false,"readme":"# hypercore-storage\n\nThe storage engine for Hypercore. Built on RocksDB.\n\n```\nnpm install hypercore-storage\n```\n\n## API\n\nThe following API is what Hypercore 11 binds to to do I/O.\n\n```js\nconst Storage = require('hypercore-storage')\n```\n\n#### `store = new Storage(dbOrPath)`\n\nMake a new storage engine.\n\n#### `core = await store.create({ key, discoveyKey, manifest?, keyPair?, encryptionKey?, userData? })`\n\nCreate a new core, returns a storage instance for that core.\n\n#### `core = await store.resume(discoveryKey)`\n\nResume a previously make core. If it doesn't exist it returns `null`.\n\n#### `atom = store.createAtom()`\n\nPrimitive for making atomic batches across ops. See below for `core.atomize` on how to use it.\nWhen you wanna flush your changes to the underlying storage, use `await atom.flush()`.\n\nInternally to \"listen\" for when that happens you can add an sync hook with `atom.onflush(fn)`\n\n#### `bool = await store.has(discoveryKey)`\n\nCheck if a core exists.\n\n#### `stream = store.createCoreStream()`\n\nList all cores. Stream data looks like this `{ discoveryKey, core }` where core contains the core header.\n\n#### `await store.close()`\n\nClose the storage instance.\n\n#### `rx = core.read()`\n\nMake a read batch on a core storage.\n\n**NOTE:** a read batch DOES NOT flush until you call `rx.tryFlush()`.\n\n#### `await rx.getAuth()`\n\nReturns the auth data around a core.\n\n#### `await rx.getHead()`\n\nReturns the head of the merkle tree.\n\n#### `await rx.getSessions()`\n\nReturns an array of all named sessions.\n\n#### `await rx.getDependency()`\n\nReturns the core this has a dependency on.\n\n#### `await rx.getHints()`\n\nReturns the various storage/replication hints.\n\n#### `await rx.getBlock(index)`\n\nReturns a block stored.\n\n#### `await rx.getTreeNode(index)`\n\nReturns a tree node stored.\n\n#### `await rx.getBitfieldPage(index)`\n\nReturn a bitfield page.\n\n#### `await rx.getUserData(key)`\n\nReturn a user stored buffer.\n\n#### `rx.tryFlush()`\n\nFlushes the read batch, non of the above promises will resolve until you call this.\n\n#### `tx = core.write()`\n\nMake a write batch on a core storage.\n\n**NOTE:** all the apis below are sync as they just buffer mutations until you flush them.\n\n#### `tx.setAuth(auth)`\n\nSet the auth data around a core.\n\n#### `tx.setHead(auth)`\n\nSet the head of the merkle tree.\n\n#### `tx.setSessions(sessions)`\n\nSet an array of all named sessions.\n\n#### `tx.setDependency(dep)`\n\nSet the core this has a dependency on.\n\n#### `tx.setHints(hints)`\n\nSet the various storage/replication hints.\n\n#### `tx.putBlock(index, buffer)`\n\nPut a block at a specific index.\n\n#### `tx.deleteBlock(index)`\n\nDelete a block at a specific index.\n\n#### `tx.deleteBlockRange(start, index)`\n\nDelete blocks between two indexes.\n\n#### `tx.putTreeNode(node)`\n\nPut a tree node (at its described index).\n\n#### `tx.deleteTreeNode(index)`\n\nDelete a tree node at a specific index.\n\n#### `tx.deleteTreeNodeRange(start, index)`\n\nDelete blocks between two tree indexes.\n\n#### `tx.putBitfieldPage(index, page)`\n\nPut a bitfield page at its described index.\n\n#### `tx.deleteBitfieldPage(index)`\n\nDelete a bitfield page.\n\n#### `tx.deleteBitfieldPageRange(start, end)`\n\nDelete bitfield pages between two indexes.\n\n#### `tx.putUserData(key, value)`\n\nPut a user provided buffer at a user provided key.\n\n#### `tx.deleteUserData(key)`\n\nDelete a user provided key.\n\n#### `await tx.flush()`\n\nFlushes the write batch.\n\n#### `stream = core.createBlockStream(opts)`\n\nCreate a stream of all blocks.\n\n#### `stream = core.createTreeNodeStream(opts)`\n\nCreate a stream of all tree nodes.\n\n#### `stream = core.createBitfieldStream(opts)`\n\nCreate a stream of all bitfield pages.\n\n#### `stream = core.createUserDataStream(opts)`\n\nCreate a stream of all user data.\n\n#### `await core.close()`\n\nClose the core storage engine.\n\n#### `atom = core.createAtom()`\n\nSame as `store.createAtom()` but here again for conveinience.\n\n#### `core = core.atomize(atom)`\n\nAtomize a core. Allows you to build up cross core atomic batches and operations.\nAn atomized core will not flush its changes until you call `atom.flush()`, but you can still read your writes.\n\n#### `core = core.createSession(name, head)`\n\nCreate a named session on top of a core. A named session points back to the previous storage,\nbut is otherwise independent and stored on disk, like a branch in git if you will.\n\n#### `core.dependencies`\n\nArray containing the full list of dependencies for this core (ie tree of named sessions).\n\n## License\n\nApache-2.0\n","publish_time":1742562809038,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"andrewosh","email":"andrewosh@gmail.com"},{"name":"chm-diederichs","email":"chm-diederichs@protonmail.com"}],"_cnpm_publish_time":1742562809038,"dist-tags":{"latest":"3.4.0"}}