hypercore-byte-stream
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -22,2 +22,3 @@ const assert = require('assert') | ||
this._downloaded = false | ||
this._ifAvailable = false | ||
@@ -29,3 +30,3 @@ if (opts.feed) { | ||
start ({ feed, blockOffset, blockLength, byteOffset, byteLength } = {}) { | ||
start ({ feed, blockOffset, blockLength, byteOffset, byteLength, ifAvailable } = {}) { | ||
assert(!this.feed, 'Can only provide options once (in the constructor, or asynchronously).') | ||
@@ -40,2 +41,3 @@ assert(feed, 'Must provide a feed') | ||
this.feed = feed | ||
this._ifAvailable = ifAvailable | ||
this._range = { | ||
@@ -55,3 +57,3 @@ start: blockOffset || 0, | ||
// end + 1 so we can support seeks to the end of the file | ||
this.feed.seek(offset, { start: this._range.start, end: this._range.end + 1 }, cb) | ||
this.feed.seek(offset, { start: this._range.start, end: this._range.end + 1, ifAvailable: this._ifAvailable }, cb) | ||
} | ||
@@ -164,3 +166,3 @@ | ||
this.feed.get(this._range.start++, { wait: !this._downloaded }, (err, data) => { | ||
this.feed.get(this._range.start++, { ifAvailable: this._ifAvailable, wait: !this._downloaded }, (err, data) => { | ||
if (err || this.destroyed) return this.destroy(err) | ||
@@ -167,0 +169,0 @@ if (this._offset) data = data.slice(this._offset) |
{ | ||
"name": "hypercore-byte-stream", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "A Readable stream wrapper around Hypercore that supports reading byte ranges.", | ||
@@ -27,3 +27,3 @@ "main": "index.js", | ||
"random-access-memory": "^3.1.1", | ||
"tape": "^4.9.2" | ||
"tape": "^5.0.1" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
@@ -167,3 +167,4 @@ const test = require('tape') | ||
byteOffset: 500, | ||
byteLength: 700 | ||
byteLength: 700, | ||
ifAvailable: false | ||
}) | ||
@@ -321,4 +322,8 @@ | ||
t.false(stream._range) | ||
if (output._selections) t.same(output._selections.length, expectedSelections) | ||
else t.pass() | ||
if (output._selections) { | ||
t.same(output._selections.length, expectedSelections) | ||
} else { | ||
console.log('PASSING') | ||
t.pass() | ||
} | ||
}) | ||
@@ -325,0 +330,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18645
487