hyperbee2 2.9.0 → 2.9.1

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.
Files changed (2) hide show
  1. package/index.js +7 -2
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -136,6 +136,11 @@ class Hyperbee extends EventEmitter {
136
136
  return new WriteBatch(this, opts)
137
137
  }
138
138
 
139
+ update(root = null) {
140
+ if (root === null) root = this._lastNodeInCore()
141
+ this._setRoot(root, true)
142
+ }
143
+
139
144
  _lastNodeInCore() {
140
145
  return this._nodeAtSeq(this.context.core.length - 1)
141
146
  }
@@ -152,7 +157,7 @@ class Hyperbee extends EventEmitter {
152
157
 
153
158
  this._setRoot(this._lastNodeInCore(), false)
154
159
  if (this.autoUpdate) {
155
- this.core.on('append', () => this._setRoot(this._lastNodeInCore(), true))
160
+ this.core.on('append', this.update.bind(this, null))
156
161
  }
157
162
 
158
163
  this.emit('ready')
@@ -256,7 +261,7 @@ class Hyperbee extends EventEmitter {
256
261
  }
257
262
 
258
263
  _setRoot(root, emit) {
259
- if (!root.equivalentTo(this.root)) {
264
+ if (root === null || !root.equivalentTo(this.root)) {
260
265
  this.root = root
261
266
  if (emit) this.emit('update')
262
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbee2",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Scalable P2P BTree",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -41,12 +41,12 @@
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",
44
- "url": "https://github.com/mafintosh/hyperbee2.git"
44
+ "url": "https://github.com/holepunchto/hyperbee2.git"
45
45
  },
46
- "author": "Mathias Buus (@mafintosh)",
46
+ "author": "Holepunch Inc.",
47
47
  "license": "Apache-2.0",
48
48
  "bugs": {
49
- "url": "https://github.com/mafintosh/hyperbee2/issues"
49
+ "url": "https://github.com/holepunchto/hyperbee2/issues"
50
50
  },
51
- "homepage": "https://github.com/mafintosh/hyperbee2"
51
+ "homepage": "https://github.com/holepunchto/hyperbee2"
52
52
  }