New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mountable-dwtrie

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mountable-dwtrie

A dwtrie wrapper that supports mounting of other dwtries

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

mountable-dwtrie

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 = dwebx(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-dwtrie re-exposes the dwtrie API, with the addition of the following methods (and a different constructor):

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

  • dwebx: any object that implements the dwebx interface. For now, it's recommanded to use random-access-dwebx
  • key is the dwtrie key
  • opts can contain any dwtrie 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 dwtrie methods. Here's what's been implemented so far:

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

License

MIT

Keywords

mount

FAQs

Package last updated on 30 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts