hypercore-storage 1.7.0 → 1.7.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.
|
@@ -27,11 +27,12 @@ module.exports = class BlockStream extends Readable {
|
|
|
27
27
|
const deps = this.core.dependencies
|
|
28
28
|
const index = this._findDependencyIndex(deps)
|
|
29
29
|
|
|
30
|
-
const curr = deps[index]
|
|
31
|
-
const prev = deps[index - 1]
|
|
30
|
+
const curr = index < deps.length ? deps[index] : null
|
|
31
|
+
const prev = (index > 0 && index - 1 < deps.length) ? deps[index - 1] : null
|
|
32
|
+
|
|
33
|
+
const start = (prev && prev.length > this.start) ? prev.length : this.start
|
|
34
|
+
const end = (curr && (this.end === -1 || curr.length < this.end)) ? curr.length : this.end
|
|
32
35
|
|
|
33
|
-
const start = prev && prev.length > this.start ? prev.length : this.start
|
|
34
|
-
const end = curr && curr.length < this.end ? curr.length : this.end
|
|
35
36
|
const ptr = curr ? curr.dataPointer : this.core.dataPointer
|
|
36
37
|
|
|
37
38
|
this._makeStream(core.block(ptr, start), core.block(ptr, end))
|