hypercore-promisifier

v1.0.2
A Hypercore wrapper that lets you switch between callback and Promise APIs
hypercore promises

hypercore-promisifier

Test on Node.js

A wrapper that provides conversion to/from callback/promise interfaces in Hypercore and RemoteHypercore.

Installation

npm i hypercore-promisifier

Usage

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

Metadata

  • MIT
  • Whatever
  • Andrew Osheroff
  • released 12/7/2020

Downloads

Maintainers