# mountable-dwebtrie

> A DWebTrie wrapper that supports mounting of other dWebTries.

Latest version **3.0.1** (published 2021-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install mountable-dwebtrie
pnpm add mountable-dwebtrie
yarn add mountable-dwebtrie
bun add mountable-dwebtrie
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-03-12 |
| First published | 2020-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 64.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | PeepsLabs |
| Maintainers | peepslabs |
| Keywords | mount, mountable, dwebtrie |

## Links

- npm: https://www.npmjs.com/package/mountable-dwebtrie
- Repository: https://github.com/dwebprotocol/mountable-dwebtrie
- Homepage: https://dwebx.org
- Issues: https://github.com/dwebprotocol/mountable-dwebtrie/issues
- npm.io page: https://npm.io/package/mountable-dwebtrie

## Dependencies (10)

- [thunky](https://npm.io/package/thunky.md) ^1.1.0
- [unixify](https://npm.io/package/unixify.md) ^1.0.0
- [dwebtrie](https://npm.io/package/dwebtrie.md) ^3.0.0
- [is-options](https://npm.io/package/is-options.md) ^1.0.1
- [nanoiterator](https://npm.io/package/nanoiterator.md) ^1.2.0
- [nanoresource](https://npm.io/package/nanoresource.md) ^1.3.0
- [protocol-buffers](https://npm.io/package/protocol-buffers.md) ^4.1.0
- [@ddatabase/crypto](https://npm.io/package/@ddatabase/crypto.md) ^1.0.0
- [@ddatabase/protocol](https://npm.io/package/@ddatabase/protocol.md) ^1.0.0
- [protocol-buffers-encodings](https://npm.io/package/protocol-buffers-encodings.md) ^1.1.0

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-03-12
- 3.0.0 — 2021-03-05
- 2.0.0 — 2020-10-21
- 1.0.0 — 2020-10-21

## README

# mountable-dwebtrie


A DWebTrie wrapper that supports mounting of sub-DWebTries.

### Usage
A MountableDWebTrie can be mounted within another MountableDWebTrie by using the `mount` command:
```js
const store = basestore(ram)
const trie1 = new MountableDWebTrie(store)
const trie2 = new MountableDWebTrie(store)

trie2.ready(() => {
  trie1.mount('/a', trie2.key, ...)
})
```
Assuming `trie2` has a value 'hello' at `/b/c`:
```js
trie1.get('/a/b/c', console.log) // Will return Buffer.from('hello')
```

A mount can be removed by performing a `del` on the mountpoint :
```js
trie1.del('/a', err => {
  trie1.get('/a/b/c', console.log) // Will print `null`
})
```
### API
`mountable-dwebtrie` re-exposes the [`dwebtrie`](https://github.com/dwebprotocol/dwebtrie) API, with the addition of the following methods (and a different constructor):

#### `const trie = new MountableDWebTrie(basestore, key, opts)`
- `basestore`: any object that implements the basestore interface. For now, it's recommanded to use [`random-access-basestore`](https://github.com/dwebprotocol/random-access-basestore)
- `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:_

- [x] `get`
- [x] `put`
- [x] `del`
- [ ] `batch`
- [x] `iterator`
- [x] `list`
- [x] `createReadStream`
- [ ] `createWriteStream`
- [x] `checkout`
- [x] `watch`
- [ ] `createHistoryStream`
- [x] `createDiffStream`

### License
MIT

---
_Source: https://npm.io/package/mountable-dwebtrie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
