Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperbee

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperbee - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3

35

index.js

@@ -300,6 +300,10 @@ const codecs = require('codecs')

this.readonly = !!opts.readonly
this.prefix = opts.prefix || null
this._sub = !!opts._sub
this._unprefixedKeyEncoding = this.keyEncoding
this._sub = !!this.prefix
this._checkout = opts.checkout || 0
this._ready = opts._ready || null
if (this.prefix) this.keyEncoding = prefixEncoding(this.prefix, this.keyEncoding)
}

@@ -456,10 +460,11 @@

if (!Buffer.isBuffer(sep)) sep = Buffer.from(sep)
prefix = Buffer.concat([Buffer.from(prefix), sep])
prefix = Buffer.concat([this.prefix || EMPTY, Buffer.from(prefix), sep])
const valueEncoding = codecs(opts.valueEncoding || this.valueEncoding)
const keyEncoding = codecs(opts.keyEncoding || this.keyEncoding)
const keyEncoding = codecs(opts.keyEncoding || this._unprefixedKeyEncoding)
return new HyperBee(this._feed, {
_sub: true,
_ready: this.ready(),
prefix,
sep: this.sep,

@@ -470,11 +475,3 @@ lock: this.lock,

valueEncoding,
keyEncoding: {
encode (key) {
return Buffer.concat([prefix, Buffer.isBuffer(key) ? key : enc(keyEncoding, key)])
},
decode (key) {
const sliced = key.slice(prefix.length, key.length)
return keyEncoding ? keyEncoding.decode(sliced) : sliced
}
}
keyEncoding
})

@@ -880,4 +877,16 @@ }

function prefixEncoding (prefix, keyEncoding) {
return {
encode (key) {
return Buffer.concat([prefix, Buffer.isBuffer(key) ? key : enc(keyEncoding, key)])
},
decode (key) {
const sliced = key.slice(prefix.length, key.length)
return keyEncoding ? keyEncoding.decode(sliced) : sliced
}
}
}
function noop () {}
module.exports = HyperBee
{
"name": "hyperbee",
"version": "1.5.2",
"version": "1.5.3",
"description": "An append-only Btree running on a Hypercore.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -237,5 +237,25 @@ const tape = require('tape')

await sub.put('a', 'b')
const node = await sub.get('a')
t.same(node && node.key, 'a')
t.same(node && node.value, 'b')
const encoded = sub.keyEncoding.encode('a')
{
const node = await sub.get('a')
t.same(node && node.key, 'a')
t.same(node && node.value, 'b')
}
{
const node = await db.get(encoded)
t.same(node && node.key, encoded.toString('utf-8'))
t.same(node && node.value, 'b')
}
{
const key = 'hello' + db.sep + 'world' + db.sep + 'a'
t.same(key, encoded.toString('utf-8'))
const node = await db.get(key)
t.same(node && node.key, key)
t.same(node && node.value, 'b')
}
t.end()

@@ -242,0 +262,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc