# networked-hyperbeedown

> LevelDB-compatible module for loading p2p databases using hyperbee and hyperswarm

Latest version **1.0.1** (published 2021-02-05) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install networked-hyperbeedown
pnpm add networked-hyperbeedown
yarn add networked-hyperbeedown
bun add networked-hyperbeedown
```

## 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 | 1.0.1 |
| Published | 2021-02-05 |
| First published | 2021-01-26 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 39 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | rangermauve |
| Maintainers | rangermauve |
| Keywords | hyperbee, level, levedb, p2p, database, db |

## Links

- npm: https://www.npmjs.com/package/networked-hyperbeedown
- Repository: https://github.com/RangerMauve/networked-hyperbeedown
- Homepage: https://github.com/RangerMauve/networked-hyperbeedown#readme
- Issues: https://github.com/RangerMauve/networked-hyperbeedown/issues
- npm.io page: https://npm.io/package/networked-hyperbeedown

## Dependencies (3)

- [hyperbee](https://npm.io/package/hyperbee.md) ^1.3.0
- [hyper-sdk](https://npm.io/package/hyper-sdk.md) ^3.0.3
- [hyperbeedown](https://npm.io/package/hyperbeedown.md) ^2.0.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-02-05
- 1.0.0 — 2021-01-26

## README

# networked-hyperbeedown
LevelDB-compatible module for loading p2p databases using hyperbee and hyperswarm

## Usage

```shell
npm i --save networked-hyperbeedown levelup
```

```
const levelup = require('levelup')
const { once } = require('events')

const NetworkedHyperbeedown = require('networked-hyperbeedown')()

const down = new NetworkedHyperbeedown('hyper://someurlhere', {
  keyEncoding: 'utf-8'
})

const db = levelup(db)

await db.open()

// Wait for an initial peer before tryinng to load data
await once(down.core, 'peer-open')

const value = await db.get('Example')

console.log('Got value from remote:', value)
```

## API

### `const NetworkedHyperbeedown = makeNetworkedHyperbeedown({Hypercore, close, ...opts})`

Creates an instance of NetworkedHyperbeeDown.

Provide a custom `Hypercore` constructor and optional `close` for cleaning up if you want full control.

Else you can pass in `opts` which will initialize [hyper-sdk](https://github.com/datproject/sdk/#const-hypercore-hyperdrive-resolvename-keypair-derivesecret-registerextension-close--await-sdkopts)

This will return a constructor for `NetworkedHyperbeedown`.

### `const hyperbeedown = new NetworkedHyperbeedown(url)`

Once you have a `NetworkedHyperbeedown` reference, you can initialize storage with urls.

The `hyperbeedown` instance returned can be passed to `levelup` or anything else that uses `abstract-leveldown`.

The `url` should be a `hyper://` URL which will be passed to the `Hypercore` constructor.

You can pass in an actual public key in the URL if you want to load from the network (which will make it readonly) like `hyper://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`.

You can also pass a custom `name` for the URL which will derive a key for you like `hyper://example`

### `const url = await hyperbeedown.getURL()`

If you used a custom `name` for your hyperbee, you can resolve it to the actual publicly accessible URL through this.

Make sure your db has been opened before calling this.

The `url` is a string.

### `const core = hyperbeedown.core`

You can get a reference to the `hypercore` with this property

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