hypercore 10.14.0 → 10.15.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.
Files changed (3) hide show
  1. package/index.js +2 -2
  2. package/lib/core.js +2 -2
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -633,9 +633,9 @@ module.exports = class Hypercore extends EventEmitter {
633
633
  }
634
634
  }
635
635
 
636
- async setUserData (key, value) {
636
+ async setUserData (key, value, { flush = false } = {}) {
637
637
  if (this.opened === false) await this.opening
638
- return this.core.userData(key, value)
638
+ return this.core.userData(key, value, flush)
639
639
  }
640
640
 
641
641
  async getUserData (key) {
package/lib/core.js CHANGED
@@ -192,7 +192,7 @@ module.exports = class Core {
192
192
  await this.blocks.put(index, value, byteOffset)
193
193
  }
194
194
 
195
- async userData (key, value) {
195
+ async userData (key, value, flush) {
196
196
  // TODO: each oplog append can set user data, so we should have a way
197
197
  // to just hitch a ride on one of the other ongoing appends?
198
198
  await this._mutex.lock()
@@ -220,7 +220,7 @@ module.exports = class Core {
220
220
 
221
221
  updateUserData(this.header.userData, key, value)
222
222
 
223
- if (this._shouldFlush()) await this._flushOplog()
223
+ if (this._shouldFlush() || flush) await this._flushOplog()
224
224
  } finally {
225
225
  this._mutex.unlock()
226
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.14.0",
3
+ "version": "10.15.0",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {