Skip to content

Repository files navigation

mountable-dwebtrie

Build Status

A dWebTrie wrapper that supports mounting of sub-dWebTries.

Usage

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

conststore=dwebstore(ram)consttrie1=newMountableDWebTrie(store)consttrie2=newMountableDWebTrie(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-dwebtrie re-exposes the dwebtrie API, with the addition of the following methods (and a different constructor):

const trie = new MountableDWebTrie(dwebstore, key, opts)

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

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

  • path is the mountpoint
  • key is the key for the MountableDWebTrie 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 dwebtrie methods. Here's what's been implemented so far:

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

License

MIT

About

A dWebTrie wrapper that supports the mounting of sub-dWebTries.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages