1.1.0 • Published 5 years ago
hypercore-promisifier v1.1.0
hypercore-promisifier
A wrapper that provides conversion to/from callback/promise interfaces in Hypercore and RemoteHypercore.
Installation
npm i hypercore-promisifierUsage
const hypercore = require('hypercore')
const ram = require('random-access-memory')
const { toPromises } = require('hypercore-promisifier')
const core = hypercore(ram)
// A promisified Hypercore interface
const wrapper = toPromises(core)API
The API supports two methods, each one returning a compatibilty wrapper around Hypercore.
const { toCallbacks, toPromises, unwrap } = require('hypercore-promisifier')
toCallbacks(core) takes a Hypercore-like object with a Promises API, and returns a wrapper with a
callbacks interfaced.
toPromises(core) takes a Hypercore-like object with a callbacks API, and returns a wrapper with a
Promises interface.
unwrap(core) takes either a wrapper object, or a normal Hypercore, and returns a normal (callbacks API) Hypercore.
License
MIT