{"name":"hypercore-storage","version":"0.0.29","author":{"name":"Holepunch"},"license":"Apache-2.0","_id":"hypercore-storage@0.0.29","dist":{"shasum":"6dae0d58610129db0972b183fcf862945a5981da","tarball":"http://registry-npm.ywwl.com/hypercore-storage/download/hypercore-storage-0.0.29.tgz","fileCount":6,"integrity":"sha512-+Tr6ed0B+hymm750qBzlRhV7W06WVGPsmSu4WoB8ikGy5zJDlH0Adw1RqIpNk2FiB2TPggkYl4luEyKf2qcTIA==","signatures":[{"sig":"MEYCIQDdeUyg+n2z3okjrbNs39jQ0kiESnaqawnn/RCM79C3dwIhAJiZOckQvUxxLeupf7+STWbxfkFy44WnZJ80HSkmYV0j","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":40870,"size":8436,"noattachment":false,"key":"/hypercore-storage/-/hypercore-storage-0.0.29.tgz"},"main":"index.js","gitHead":"061ee8189d65c23eef4765e3fd83b8b4afc67b23","scripts":{"test":"standard && brittle test/*.js"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"_npmVersion":"10.7.0","description":"RocksDB storage driver for Hypercore","directories":{},"_nodeVersion":"20.11.1","dependencies":{"b4a":"^1.6.6","streamx":"^2.20.1","flat-tree":"^1.10.0","nanoassert":"^2.0.0","index-encoder":"^3.0.1","rocksdb-native":"^2.2.0","compact-encoding":"^2.15.0","hypercore-errors":"^1.3.0","read-write-mutexify":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^3.5.2","standard":"^17.1.0","test-tmp":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/hypercore-storage_0.0.29_1732652769071_0.51213610519746","host":"s3://npm-registry-packages"},"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":1732652769234,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"andrewosh","email":"andrewosh@gmail.com"},{"name":"chm-diederichs","email":"chm-diederichs@protonmail.com"}],"_cnpm_publish_time":1732652769234,"dist-tags":{"latest":"3.4.0"}}