hypercore-byte-stream
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -30,3 +30,2 @@ const assert = require('assert') | ||
assert(!this.feed, 'Can only provide options once (in the constructor, or asynchronously).') | ||
assert(feed, 'Must provide a feed') | ||
@@ -33,0 +32,0 @@ assert(!this._opened, 'Cannot call start multiple after streaming has started.') |
{ | ||
"name": "hypercore-byte-stream", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "A Readable stream wrapper around Hypercore that supports reading byte ranges.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,2 @@ const test = require('tape') | ||
test(`${tag}: stream entire feed`, t => { | ||
t.plan(1 + 10) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -19,3 +18,5 @@ t.error(err, 'create stream ok') | ||
offset += data.length | ||
if (offset === combined.length) stream.destroy() | ||
}) | ||
stream.on('close', () => t.end()) | ||
stream.on('error', err => { | ||
@@ -28,3 +29,2 @@ t.error(err) | ||
test(`${tag}: stream with byteOffset, no length, no bounds`, t => { | ||
t.plan(1 + 8) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -43,3 +43,5 @@ t.error(err, 'create stream ok') | ||
offset += data.length | ||
if (offset === combined.length) stream.destroy() | ||
}) | ||
stream.on('close', () => t.end()) | ||
stream.on('error', err => { | ||
@@ -52,3 +54,2 @@ t.error(err) | ||
test(`${tag}: stream with byteOffset, length, no bounds`, t => { | ||
t.plan(1 + 2) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -70,2 +71,6 @@ t.error(err, 'create stream ok') | ||
}) | ||
stream.on('end', () => { | ||
t.same(offset, 50) | ||
t.end() | ||
}) | ||
stream.on('error', err => { | ||
@@ -78,3 +83,2 @@ t.error(err) | ||
test(`${tag}: stream with byteOffset, length, start bound`, t => { | ||
t.plan(1 + 2) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -97,2 +101,6 @@ t.error(err, 'create stream ok') | ||
}) | ||
stream.on('end', () => { | ||
t.same(offset, 50) | ||
t.end() | ||
}) | ||
stream.on('error', err => { | ||
@@ -105,3 +113,2 @@ t.error(err) | ||
test(`${tag}: stream with byteOffset, length, start and end bounds`, t => { | ||
t.plan(1 + 2) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -125,2 +132,6 @@ t.error(err, 'create stream ok') | ||
}) | ||
stream.on('end', () => { | ||
t.same(offset, 50) | ||
t.end() | ||
}) | ||
stream.on('error', err => { | ||
@@ -175,6 +186,9 @@ t.error(err) | ||
let offset = 0 | ||
let destroyed = false | ||
stream.on('data', data => { | ||
if (destroyed) return | ||
if (offset >= 500) { | ||
t.same(data, newData.slice(0, data.length)) | ||
return t.end() | ||
destroyed = true | ||
return stream.destroy() | ||
} | ||
@@ -184,2 +198,3 @@ t.same(data, combined.slice(offset, offset + data.length), 'chunks are the same') | ||
}) | ||
stream.on('close', () => t.end()) | ||
stream.on('error', err => { | ||
@@ -192,3 +207,2 @@ t.error(err) | ||
test(`${tag}: reads will be resumed after start`, t => { | ||
t.plan(2) | ||
create(10, 100, (err, input, output, stream, records) => { | ||
@@ -199,3 +213,5 @@ t.error(err, 'create stream ok') | ||
t.true(data) | ||
stream.destroy() | ||
}) | ||
stream.on('close', () => t.end()) | ||
@@ -227,2 +243,3 @@ setTimeout(() => { | ||
} catch (err) { | ||
stream.destroy() | ||
t.true(err) | ||
@@ -229,0 +246,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
18396
480