hypercore-promisifier
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -294,3 +294,4 @@ const { EventEmitter } = require('events') | ||
toPromises, | ||
toCallbacks | ||
toCallbacks, | ||
unwrap | ||
} | ||
@@ -306,2 +307,6 @@ | ||
function unwrap (core) { | ||
return core[CORE] || core | ||
} | ||
function maybeOptional (cb, prom) { | ||
@@ -308,0 +313,0 @@ prom = maybe(cb, prom) |
{ | ||
"name": "hypercore-promisifier", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "A Hypercore wrapper that lets you switch between callback and Promise APIs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,3 +26,3 @@ # hypercore-promisifier | ||
#### `const { toCallbacks, toPromises } = require('hypercore-promisifier')` | ||
#### `const { toCallbacks, toPromises, unwrap } = require('hypercore-promisifier')` | ||
@@ -35,4 +35,6 @@ `toCallbacks(core)` takes a Hypercore-like object with a Promises API, and returns a wrapper with a | ||
`unwrap(core)` takes either a wrapper object, or a normal Hypercore, and returns a normal (callbacks API) Hypercore. | ||
## License | ||
MIT | ||
const test = require('tape') | ||
const hypercore = require('hypercore') | ||
const ram = require('random-access-memory') | ||
// const hyperspaceSimulator = require('hyperspace/simulator') | ||
const { toPromises } = require('..') | ||
const { toPromises, unwrap } = require('..') | ||
@@ -48,1 +47,9 @@ test('cb hypercore -> promises, simple', async t => { | ||
}) | ||
test('can unwrap', async t => { | ||
const core = hypercore(ram, { valueEncoding: 'utf-8' }) | ||
const wrapper = toPromises(toPromises(core)) | ||
t.same(core, unwrap(wrapper)) | ||
t.same(core, unwrap(core)) | ||
t.end() | ||
}) |
11374
305
39