hypercore-storage 1.1.0 → 1.1.2

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.
@@ -25,8 +25,7 @@ module.exports = class BlockStream extends Readable {
25
25
  if (this._consumed > this.core.dependencies.length) return
26
26
 
27
27
  const deps = this.core.dependencies
28
-
29
- const index = findDependencyIndex(deps, this.end, this._consumed++, this.reverse)
28
+ const index = this._findDependencyIndex(deps)
30
29
 
31
30
  const curr = deps[index]
32
31
  const prev = deps[index - 1]
@@ -38,6 +37,19 @@ module.exports = class BlockStream extends Readable {
38
37
  this._makeStream(core.block(ptr, start), core.block(ptr, end))
39
38
  }
40
39
 
40
+ _findDependencyIndex (deps) {
41
+ if (!this.reverse) return this._consumed++
42
+
43
+ let i = deps.length - this._consumed++
44
+ while (i > 0) {
45
+ if (deps[i - 1].length <= this.end) return i
46
+ i--
47
+ this._consumed++
48
+ }
49
+
50
+ return 0
51
+ }
52
+
41
53
  _predestroy () {
42
54
  if (this._stream !== null) this._stream.destroy()
43
55
  }
@@ -83,7 +95,7 @@ module.exports = class BlockStream extends Readable {
83
95
  // empty the current stream
84
96
  if (this._onreadable() === true) this._drained = true
85
97
 
86
- this._stream = this._start = this._end = null
98
+ this._stream = null
87
99
 
88
100
  this._update()
89
101
  this._maybeDrain()
@@ -98,13 +110,3 @@ module.exports = class BlockStream extends Readable {
98
110
  }
99
111
 
100
112
  function noop () {}
101
-
102
- function findDependencyIndex (deps, end, offset, reverse) {
103
- if (!reverse) return offset
104
-
105
- for (let i = deps.length - offset; i > 0; i--) {
106
- if (deps[i - 1].length <= end) return i
107
- }
108
-
109
- return 0
110
- }
package/lib/view.js CHANGED
@@ -266,8 +266,8 @@ class View {
266
266
  return
267
267
  }
268
268
 
269
- if (this.changes.length === this.indexed) return
270
269
  if (this.map === null) this.map = new Map()
270
+ if (this.changes.length === this.indexed) return
271
271
 
272
272
  while (this.indexed < this.changes.length) {
273
273
  const c = this.changes[this.indexed++]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",