mountable-hypertrie

A Hypertrie wrapper that supports mounting of other Hypertries

MIT 48 个版本
安装
npm install mountable-hypertrie
yarn add mountable-hypertrie
pnpm add mountable-hypertrie
bun add mountable-hypertrie
README

mountable-hypertrie

Build Status

A Hypertrie wrapper that supports mounting of sub-Hypertries.

Usage

A MountableHypertrie can be mounted within another MountableHypertrie by using the mount command:

const store = corestore(ram)
const trie1 = new MountableHypertrie(store)
const trie2 = new MountableHypertrie(store)

trie2.ready(() => {
  trie1.mount('/a', trie2.key, ...)
})

Assuming trie2 has a value 'hello' at /b/c:

trie1.get('/a/b/c', console.log) // Will return Buffer.from('hello')

A mount can be removed by performing a del on the mountpoint :

trie1.del('/a', err => {
  trie1.get('/a/b/c', console.log) // Will print `null`
})

API

mountable-hypertrie re-exposes the hypertrie API, with the addition of the following methods (and a different constructor):

const trie = new MountableHypertrie(corestore, key, opts)

  • corestore: any object that implements the corestore interface. For now, it's recommanded to use random-access-corestore
  • key is the hypertrie key
  • opts can contain any hypertrie options

trie.mount(path, key, opts, cb)

  • path is the mountpoint
  • key is the key for the MountableHypertrie to be mounted at path

opts can include:

{
  remotePath: '/remote/path', // An optional base path within the mount.
  version: 1                  // An optional checkout version
}

Note: We're still adding support for many hypertrie methods. Here's what's been implemented so far:

  • get
  • put
  • del
  • batch
  • iterator
  • list
  • createReadStream
  • createWriteStream
  • checkout
  • watch
  • createHistoryStream
  • createDiffStream

License

MIT

版本列表
2.8.0 2020-09-10
2.7.0 2020-08-13
2.6.0 2020-06-04
2.5.3 2020-05-14
2.5.2 2020-05-13
2.5.1 2020-05-13
2.5.0 2020-05-13
2.4.15 2020-05-11
2.4.14 2020-03-26
2.4.13 2020-03-23
2.4.12 2020-03-10
2.4.11 2020-03-10
2.4.10 2020-02-17
2.4.9 2020-02-12
2.4.8 2020-02-06
2.4.7 2020-01-22
2.4.6 2020-01-22
2.4.5 2020-01-22
2.4.4 2020-01-21
2.4.3 2020-01-15
2.4.2 2020-01-14
2.4.1 2020-01-13
2.4.0 2020-01-08
2.3.1 2020-01-08
2.3.0 2020-01-06
2.2.0 2019-12-20
2.1.0 2019-12-17
2.0.3 2019-11-23
2.0.2 2019-11-23
2.0.1 2019-11-19
2.0.0 2019-11-19
1.0.1 2019-10-23
1.0.0 2019-09-24
0.11.1 2019-09-05
0.11.0 2019-08-14
0.10.4 2019-08-07
0.10.3 2019-07-11
0.10.2 2019-07-11
0.10.1 2019-07-11
0.10.0 2019-07-09
0.9.7 2019-07-08
0.9.6 2019-06-23
0.9.5 2019-06-20
0.9.4 2019-06-20
0.9.3 2019-06-20
0.9.2 2019-06-17
0.9.1 2019-05-24
0.9.0 2019-05-24