{"name":"hypercore-storage","version":"1.2.2","author":{"name":"Holepunch Inc."},"license":"Apache-2.0","_id":"hypercore-storage@1.2.2","dist":{"shasum":"d986a9e003bf191731c0f499947b9f8c2b7f565b","tarball":"http://registry-npm.ywwl.com/hypercore-storage/download/hypercore-storage-1.2.2.tgz","fileCount":13,"integrity":"sha512-anie6iqjlNwdZZBFDVA2dwopUvXON3TZ1Ua+J/Tq7DUItHoVBVpaZRSc4+zTPVXBem1vzed6zCW89XWteihDww==","signatures":[{"sig":"MEYCIQDzEoclivcqF52xeO4nENZWdSYEKB+AFxPzn2WZY3885QIhAMGKGN3QnLhXnflYHQvzc/YUCjKsUQRUhVr85mNLmzx2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":117003,"size":24629,"noattachment":false,"key":"/hypercore-storage/-/hypercore-storage-1.2.2.tgz"},"main":"index.js","gitHead":"6f025cda729636a740d5cf8fa7c68e514b74d84c","imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"scripts":{"test":"standard && node test/all.js","test:bare":"bare test/all.js","test:generate":"brittle -r test/all.js test/*.js"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"_npmVersion":"10.9.0","description":"Storage engine for Hypercore","directories":{},"_nodeVersion":"22.12.0","dependencies":{"b4a":"^1.6.7","bare-fs":"^4.0.1","streamx":"^2.21.1","bare-path":"^3.0.0","flat-tree":"^1.12.1","scope-lock":"^1.2.4","hyperschema":"^1.7.0","index-encoder":"^3.3.2","rocksdb-native":"^3.1.1","compact-encoding":"^2.16.0","hypercore-crypto":"^3.4.2","resolve-reject-promise":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^3.7.0","standard":"^17.1.2","test-tmp":"^1.3.1"},"_npmOperationalInternal":{"tmp":"tmp/hypercore-storage_1.2.2_1740146542888_0.6045729410770266","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)`\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":1740146543083,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"andrewosh","email":"andrewosh@gmail.com"},{"name":"chm-diederichs","email":"chm-diederichs@protonmail.com"}],"_cnpm_publish_time":1740146543083,"dist-tags":{"latest":"3.4.0"}}