0.2.0 • Published 1 year ago

hyperpubee-hyper-interface v0.2.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

Hyperpubee Hyper Interface

Small interface on top of hypercore to facilitate creating and reading hypercores and hyperbees in a single corestore.

Install

npm add hyperpubee-hyper-interface

Usage

Note: this example uses random-access-memory (needs to be installed).

const Corestore = require('corestore')
const ram = require('random-access-memory')
const HyperInterface = require('hyperpubee-hyper-interface')

const corestore = new Corestore(ram)

// opts passed to every bee created/read through this interface (by default uses hyperbee's defaults)
const defaultBeeOpts = { keyEncoding: 'utf-8', valueEncoding: 'utf-8' }

const hyperInterface = new HyperInterface(corestore, { defaultBeeOpts })
await hyperInterface.ready()

const bee = await hyperInterface.createBee('testbee')
await bee.put('myKey', 'myValue')

const readBee = await hyperInterface.readBee(bee.feed.key)
const { value } = await readBee.get('myKey')
console.log(value) // 'myValue'

// Or getting the entry directly (optional version param)
const entry = await hyperInterface.getEntry({hash: bee.feed.key, location: 'myKey'})
console.log(entry) // 'myValue'

Equivalent for hypercore with hyperInterface.readCore and hyperInterface.createCore

0.2.0

1 year ago

0.1.4

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago