hyperbee2 2.4.4 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -99,6 +99,14 @@ class Hyperbee {
99
99
  return this._makeView(context, root, writable, 0)
100
100
  }
101
101
 
102
+ move({ length = this.core.length, key = null, writable = this.writable } = {}) {
103
+ const context = key ? this.context.getContextByKey(key) : this.context
104
+ const root = length === 0 ? EMPTY : context.createTreeNode(0, length - 1, 0, false, null)
105
+ this.context = context
106
+ this.writable = writable
107
+ this.root = root
108
+ }
109
+
102
110
  snapshot() {
103
111
  return this._makeView(this.context, this.root, false, 0)
104
112
  }
package/lib/changes.js CHANGED
@@ -26,6 +26,7 @@ class ChangesStream extends Readable {
26
26
 
27
27
  const data = {
28
28
  head: this.head,
29
+ tail: null,
29
30
  batch: []
30
31
  }
31
32
 
@@ -41,16 +42,17 @@ class ChangesStream extends Readable {
41
42
  for (const blk of await Promise.all(remaining)) data.batch.push(blk)
42
43
  data.batch.push(blk)
43
44
 
44
- this.push(data)
45
-
46
45
  if (!blk.previous) {
47
46
  this.head = null
48
47
  this.context = null
48
+ this.push(data)
49
49
  return
50
50
  }
51
51
 
52
52
  this.context = await this.context.getContext(blk.previous.core, this.config)
53
- this.head = { key: this.context.core.key, length: blk.previous.seq + 1 }
53
+ this.head = data.tail = { key: this.context.core.key, length: blk.previous.seq + 1 }
54
+
55
+ this.push(data)
54
56
  }
55
57
 
56
58
  async _open(cb) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbee2",
3
- "version": "2.4.4",
3
+ "version": "2.6.0",
4
4
  "description": "btree",
5
5
  "main": "index.js",
6
6
  "files": [