Comparing version 2.18.2 to 2.19.0
34
index.js
@@ -251,2 +251,10 @@ const codecs = require('codecs') | ||
updateChildren (seq, block) { | ||
for (const child of this.children) { | ||
if (!child.value || child.seq !== seq) continue | ||
child.value.block = block | ||
child.value.updateChildren(seq, block) | ||
} | ||
} | ||
static create (block) { | ||
@@ -1029,6 +1037,8 @@ const node = new TreeNode(block, [], [], 0) | ||
const block = new BatchEntry(seq, this, key, value, index) | ||
if (!root.block) root.block = block | ||
root.block = block | ||
this.root = root | ||
this.length++ | ||
this.blocks.set(seq, block) | ||
root.updateChildren(seq, block) | ||
return | ||
@@ -1149,4 +1159,6 @@ } | ||
this._updateOnce = !!opts.updateOnce | ||
this._onchange = opts.onchange || null | ||
this.on('newListener', autoFlowOnUpdate) | ||
this.ready().catch(safetyCatch) | ||
@@ -1172,2 +1184,7 @@ } | ||
this.current = this._eager ? this.bee.checkout(1, opts) : this.bee.snapshot(opts) | ||
if (this._onchange) { | ||
if (this._eager) await this._onchange() | ||
this._consume() | ||
} | ||
} | ||
@@ -1240,3 +1257,3 @@ | ||
if (this.current.core.fork !== this.previous.core.fork) { | ||
return this._yield() | ||
return await this._yield() | ||
} | ||
@@ -1248,3 +1265,3 @@ | ||
for await (const data of this.stream) { // eslint-disable-line | ||
return this._yield() | ||
return await this._yield() | ||
} | ||
@@ -1260,5 +1277,14 @@ } finally { | ||
_yield () { | ||
async _yield () { | ||
this.currentMapped = this.map(this.current) | ||
this.previousMapped = this.map(this.previous) | ||
if (this._onchange) { | ||
try { | ||
await this._onchange() | ||
} catch (err) { | ||
safetyCatch(err) | ||
} | ||
} | ||
this.emit('update') | ||
@@ -1265,0 +1291,0 @@ return { done: false, value: [this.currentMapped, this.previousMapped] } |
{ | ||
"name": "hyperbee", | ||
"version": "2.18.2", | ||
"version": "2.19.0", | ||
"description": "An append-only B-tree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
94815
2615