# mountable-hypertrie

> A Hypertrie wrapper that supports mounting of other Hypertries

Latest version **2.8.0** (published 2020-09-10) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.8.0 |
| Published | 2020-09-10 |
| First published | 2019-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 66.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Andrew Osheroff |
| Maintainers | andrewosh |
| Keywords | mount, mountable, hypertrie |

## Links

- npm: https://www.npmjs.com/package/mountable-hypertrie
- Repository: https://github.com/andrewosh/mountable-hypertrie
- Homepage: https://github.com/andrewosh/mountable-hypertrie#readme
- Issues: https://github.com/andrewosh/mountable-hypertrie/issues
- npm.io page: https://npm.io/package/mountable-hypertrie

## Dependencies (10)

- [thunky](https://npm.io/package/thunky.md) ^1.1.0
- [unixify](https://npm.io/package/unixify.md) ^1.0.0
- [hypertrie](https://npm.io/package/hypertrie.md) ^5.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
- [hypercore-crypto](https://npm.io/package/hypercore-crypto.md) ^2.0.1
- [protocol-buffers](https://npm.io/package/protocol-buffers.md) ^4.1.0
- [hypercore-protocol](https://npm.io/package/hypercore-protocol.md) ^8.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

- 2.8.0 (latest) — 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
- … 33 more at https://npm.io/package/mountable-hypertrie/versions

## README

# mountable-hypertrie
[![Build Status](https://travis-ci.com/andrewosh/mountable-hypertrie.svg?token=WgJmQm3Kc6qzq1pzYrkx&branch=master)](https://travis-ci.com/andrewosh/mountable-hypertrie)

A Hypertrie wrapper that supports mounting of sub-Hypertries.

### Usage
A MountableHypertrie can be mounted within another MountableHypertrie by using the `mount` command:
```js
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`:
```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-hypertrie` re-exposes the [`hypertrie`](https://github.com/mafintosh/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`](https://github.com/andrewosh/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:_

- [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-hypertrie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
