hypercore-storage 1.5.0 → 1.5.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.
- package/lib/view.js +17 -8
- package/package.json +1 -1
package/lib/view.js
CHANGED
|
@@ -51,15 +51,16 @@ class OverlayStream extends Readable {
|
|
|
51
51
|
|
|
52
52
|
_onreadable () {
|
|
53
53
|
let data = this._stream.read()
|
|
54
|
-
|
|
55
54
|
if (data === null) return false
|
|
56
55
|
|
|
56
|
+
let drained = false
|
|
57
|
+
|
|
57
58
|
do {
|
|
58
|
-
this._push(data)
|
|
59
|
+
if (this._push(data) === true) drained = true
|
|
59
60
|
data = this._stream.read()
|
|
60
61
|
} while (data !== null)
|
|
61
62
|
|
|
62
|
-
return
|
|
63
|
+
return drained
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
_read (cb) {
|
|
@@ -85,12 +86,14 @@ class OverlayStream extends Readable {
|
|
|
85
86
|
|
|
86
87
|
// we didnt move past and are in, drop
|
|
87
88
|
if (b4a.compare(c[0], key) <= 0 && b4a.compare(key, c[2]) < 0) {
|
|
88
|
-
return
|
|
89
|
+
return false
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
break
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
let updated = false
|
|
96
|
+
|
|
94
97
|
while (this.change < this.changes.length) {
|
|
95
98
|
const c = this.changes[this.change]
|
|
96
99
|
const key = c[0]
|
|
@@ -100,20 +103,26 @@ class OverlayStream extends Readable {
|
|
|
100
103
|
// same value, if not deleted, return new one
|
|
101
104
|
if (cmp === 0) {
|
|
102
105
|
this.change++
|
|
103
|
-
|
|
106
|
+
if (value === null || this._inRange(key) === false) return updated
|
|
107
|
+
this.push({ key, value })
|
|
108
|
+
return true
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
// we moved past the change, push it
|
|
107
112
|
if (this.reverse ? cmp > 0 : cmp < 0) {
|
|
108
113
|
this.change++
|
|
109
|
-
if (value
|
|
114
|
+
if (value === null || this._inRange(key) === false) continue
|
|
115
|
+
this.push({ key, value })
|
|
116
|
+
updated = true
|
|
110
117
|
continue
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
|
|
120
|
+
this.push(entry)
|
|
121
|
+
return true
|
|
114
122
|
}
|
|
115
123
|
|
|
116
|
-
|
|
124
|
+
this.push(entry)
|
|
125
|
+
return true
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
_inRange (key) {
|