Comparing version 1.5.1 to 1.5.2
10
index.js
@@ -17,3 +17,3 @@ const codecs = require('codecs') | ||
const SEP = Buffer.alloc(1) | ||
const MAX = Buffer.from([255]) | ||
const EMPTY = Buffer.alloc(0) | ||
@@ -861,6 +861,12 @@ class Key { | ||
if (opts.sub && !opts.gt && !opts.gte) opts.gt = enc(e, SEP) | ||
if (opts.sub && !opts.lt && !opts.lte) opts.lt = enc(e, MAX) | ||
if (opts.sub && !opts.lt && !opts.lte) opts.lt = bump(enc(e, EMPTY)) | ||
return opts | ||
} | ||
function bump (key) { | ||
// key should have been copied by enc above before hitting this | ||
key[key.length - 1]++ | ||
return key | ||
} | ||
function enc (e, v) { | ||
@@ -867,0 +873,0 @@ if (v === undefined || v === null) return null |
{ | ||
"name": "hyperbee", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "An append-only Btree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -287,2 +287,3 @@ const tape = require('tape') | ||
const node = await helloSub.get({ key: 'hello' }) | ||
t.ok(node) | ||
@@ -292,2 +293,21 @@ t.end() | ||
tape('sub with a key that starts with 0xff', async t => { | ||
t.plan(2) | ||
const db = create({ sep: '!', keyEncoding: 'binary' }) | ||
const helloSub = db.sub('hello') | ||
const key = Buffer.from([0xff, 0x01, 0x02]) | ||
await helloSub.put(key, 'val') | ||
for await (const data of helloSub.createReadStream()) { | ||
t.same(data.key, key) | ||
} | ||
const node = await helloSub.get(key) | ||
t.ok(node) | ||
t.end() | ||
}) | ||
tape('setting read-only flag to false disables header write', async t => { | ||
@@ -294,0 +314,0 @@ const db = create({ readonly: true }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95785
2851