{"name":"hypercore-storage","version":"3.3.2","author":{"name":"Holepunch"},"license":"Apache-2.0","_id":"hypercore-storage@3.3.2","maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"homepage":"https://github.com/holepunchto/hypercore-storage#readme","bugs":{"url":"https://github.com/holepunchto/hypercore-storage/issues"},"dist":{"shasum":"f1e850969627b8e8d4b625eeb4fd175aaee5b138","tarball":"http://registry-npm.ywwl.com/hypercore-storage/download/hypercore-storage-3.3.2.tgz","fileCount":16,"integrity":"sha512-XbyyNRL/F71jUbveyulmtLDIy/RnxpXZmfxb8IZqxy0Aw8t2IJu48AWuO/FZuPRDj9xpo6K2gFJMNeE1C3zrJg==","signatures":[{"sig":"MEYCIQDkmqjy8pWr/Jm4c6/IJxpcUrR25ZKs/dUTSokN0O9tdAIhAIY5zjHDKgj3HjMjHi8yJevNNXGeaTCvsEWo/eqPBatl","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQCYAU4WSuF7DTGXnBG/4bYOd3OeckAXjTi7Uh2fNZZhrwIgUqrRxOKkOOSMk0mIin6lRJ38Rl3w4rvp/yU/J62KAcQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/hypercore-storage@3.3.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":164018,"size":32782,"noattachment":false,"key":"/hypercore-storage/-/hypercore-storage-3.3.2.tgz"},"main":"index.js","gitHead":"ac095f14f8ca8d07644cdce823c1b58775818a77","imports":{"fs":{"bare":"bare-fs","default":"fs"},"os":{"bare":"bare-os","default":"os"},"fs/*":{"bare":"bare-fs/*","default":"fs/*"},"path":{"bare":"bare-path","default":"path"}},"scripts":{"lint":"prettier --check . && lunte","test":"npm run test:node && npm run test:bare","format":"prettier --write .","test:bare":"brittle-bare test/all.js","test:node":"brittle-node test/all.js","test:generate":"brittle -r test/all.js test/*.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"0868d756-a737-47fb-aead-fe2a8cc5d447"}},"repository":{"url":"git+https://github.com/holepunchto/hypercore-storage.git","type":"git"},"_npmVersion":"11.19.0","description":"Storage engine for Hypercore","directories":{},"_nodeVersion":"24.21.0","dependencies":{"b4a":"^1.6.7","xache":"^1.2.1","streamx":"^2.21.1","bare-path":"^3.0.0","flat-tree":"^1.12.1","scope-lock":"^1.2.4","device-file":"^2.1.2","hyperschema":"^1.21.0","index-encoder":"^3.3.2","rocksdb-native":"^3.18.0","compact-encoding":"^3.1.0","hypercore-crypto":"^3.4.2","resolve-reject-promise":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"lunte":"^1.3.0","bare-os":"^3.9.1","brittle":"^3.7.0","prettier":"^3.6.2","test-tmp":"^1.3.1","hypercore-storage-2.9.0":"npm:hypercore-storage@^2.9.0","prettier-config-holepunch":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hypercore-storage_3.3.2_1791366877795_0.658488979240345","host":"s3://npm-registry-packages-npm-production"},"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, opts = {})`\n\nMake a new storage engine.\n\n`opts` includes:\n\n```\n{\n  treeCache: {    // Same options as `xache`\n    maxSize: 8192 // Max number of tree nodes to cache\n  },\n  onresume: null  // Called with the discovery key when `resumeCore` is invoked,\n                  // before the lookup, so it fires even if the core does not exist\n}\n```\n\n#### `core = await store.createCore({ key, discoveyKey, manifest?, keyPair?, encryptionKey?, userData? })`\n\nCreate a new core, returns a storage instance for that core.\n\n#### `core = await store.resumeCore(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.hasCore(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. `key` is a string.\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`. `key` is a string.\n\n#### `tx.deleteUserData(key)`\n\nDelete a user provided `key`. `key` is a string.\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. `opts` is a query object with the following possible properties:\n\n```\n{\n  gt: 'only return keys > than this', // Not currently supported\n  gte: 'only return keys >= than this',\n  lt: 'only return keys < than this',\n  lte: 'only return keys <= than this', // Not currently supported\n  reverse: false // reverse results. Not currently supported\n}\n```\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":1791366877881,"_cnpm_publish_time":1791366877881,"dist-tags":{"latest":"3.4.0"}}