+23
-4
@@ -15,2 +15,3 @@ module.exports = class RangeIterator { | ||
| this._checkpoint = (opts.checkpoint && opts.checkpoint.length) ? opts.checkpoint : null | ||
| this._nexting = false | ||
| } | ||
@@ -20,3 +21,5 @@ | ||
| const checkpoint = [] | ||
| for (const { node, i } of this.stack) { | ||
| for (const s of this.stack) { | ||
| let { node, i } = s | ||
| if (this._nexting && s === this.stack[this.stack.length - 1]) i = this._reverse ? i + 1 : i - 1 | ||
| if (!node.block) continue | ||
@@ -59,4 +62,9 @@ if (i < 0) continue | ||
| this._nexting = true | ||
| let node = await this.db.getRoot() | ||
| if (!node) return | ||
| if (!node) { | ||
| this._nexting = false | ||
| return | ||
| } | ||
@@ -68,2 +76,3 @@ const incl = this._reverse ? this._lIncl : this._gIncl | ||
| this.stack.push({ node, i: this._reverse ? node.keys.length << 1 : 0 }) | ||
| this._nexting = false | ||
| return | ||
@@ -87,3 +96,3 @@ } | ||
| this.stack.push(entry) | ||
| return | ||
| break | ||
| } | ||
@@ -99,9 +108,17 @@ | ||
| if (entry.i >= 0 && entry.i <= (node.keys.length << 1)) this.stack.push(entry) | ||
| if (!node.children.length) return | ||
| if (!node.children.length) break | ||
| node = await node.getChildNode(i) | ||
| } | ||
| this._nexting = false | ||
| } | ||
| async next () { | ||
| // TODO: this nexting flag is only needed if someone asks for a snapshot during | ||
| // a lookup (ie the extension, pretty important...). | ||
| // A better solution would be to refactor this so top.i is incremented eagerly | ||
| // to get the current block instead of the way it is done now (++i vs i++) | ||
| this._nexting = true | ||
| const end = this._reverse ? this._gKey : this._lKey | ||
@@ -140,5 +157,7 @@ const incl = this._reverse ? this._gIncl : this._lIncl | ||
| if (this._limit > 0) this._limit-- | ||
| this._nexting = false | ||
| return block.final() | ||
| } | ||
| this._nexting = false | ||
| return null | ||
@@ -145,0 +164,0 @@ } |
+1
-1
| { | ||
| "name": "hyperbee", | ||
| "version": "0.0.16", | ||
| "version": "0.0.17", | ||
| "description": "An append-only Btree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
88463
0.74%2645
0.61%