Skip to content

andrewosh/hypercore-promisifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published