Comparing version
16
index.js
@@ -1029,7 +1029,15 @@ const codecs = require('codecs') | ||
this._lock = mutexify() | ||
this._flowing = false | ||
this._resolveOnChange = null | ||
this._differ = opts.differ || defaultDiffer | ||
this.on('newListener', autoFlowOnUpdate) | ||
this.ready().catch(safetyCatch) | ||
} | ||
this._differ = opts.differ || defaultDiffer | ||
async _consume () { | ||
if (this._flowing) return | ||
try { | ||
for await (const _ of this) {} // eslint-disable-line | ||
} catch {} | ||
} | ||
@@ -1048,2 +1056,3 @@ | ||
[Symbol.asyncIterator] () { | ||
this._flowing = true | ||
return this | ||
@@ -1112,2 +1121,3 @@ } | ||
this.previousMapped = this.map(this.previous) | ||
this.emit('update') | ||
return { done: false, value: [this.currentMapped, this.previousMapped] } | ||
@@ -1166,2 +1176,6 @@ } | ||
function autoFlowOnUpdate (name) { | ||
if (name === 'update') this._consume() | ||
} | ||
function defaultWatchMap (snapshot) { | ||
@@ -1168,0 +1182,0 @@ return snapshot |
{ | ||
"name": "hyperbee", | ||
"version": "2.11.1", | ||
"version": "2.12.0", | ||
"description": "An append-only B-tree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
89604
0.39%2481
0.53%