Comparing version 1.4.0 to 1.5.0
20
index.js
@@ -55,2 +55,11 @@ const codecs = require('codecs') | ||
} | ||
hasKey (seq) { | ||
for (const lvl of this.levels) { | ||
for (const key of lvl.keys) { | ||
if (key.seq === seq) return true | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
@@ -220,2 +229,13 @@ | ||
isDeletion () { | ||
if (this.value !== null) return false | ||
if (this.index === null) { | ||
this.index = inflate(this.indexBuffer) | ||
this.indexBuffer = null | ||
} | ||
return !this.index.hasKey(this.seq) | ||
} | ||
final () { | ||
@@ -222,0 +242,0 @@ return { |
@@ -29,9 +29,14 @@ module.exports = class HistoryIterator { | ||
if (this.lt <= 1) return null | ||
return (await this.db.getBlock(--this.lt, this.options)).final() | ||
return final(await this.db.getBlock(--this.lt, this.options)) | ||
} | ||
return (await this.db.getBlock(this.gte++, this.options)).final() | ||
return final(await this.db.getBlock(this.gte++, this.options)) | ||
} | ||
} | ||
function final (node) { | ||
const type = node.isDeletion() ? 'del' : 'put' | ||
return { type, ...node.final() } | ||
} | ||
function gte (opts, version) { | ||
@@ -38,0 +43,0 @@ if (opts.gt) return (opts.gt < 0 ? (opts.gt + version) : opts.gt) + 1 |
{ | ||
"name": "hyperbee", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "An append-only Btree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -124,2 +124,3 @@ # Hyperbee 🐝 | ||
Create a stream of all entries ever inserted or deleted from the db. | ||
Each entry has an additional `type` property indicating if it was a `put` or `del` operation. | ||
@@ -126,0 +127,0 @@ Options include: |
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
94745
2813
206