From 483973cf25d384e9eeb2d57d4f35c3c6d5fcb847 Mon Sep 17 00:00:00 2001 From: Nick K Date: Mon, 26 Apr 2021 13:06:27 +0300 Subject: [PATCH] Fix for the 'start' range of BlobDataItem when reading its stream (#85) Set default value for 'start' option --- from.js | 2 +- test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/from.js b/from.js index 546edfa..bdca282 100644 --- a/from.js +++ b/from.js @@ -23,7 +23,7 @@ class BlobDataItem { constructor(options) { this.size = options.size; this.path = options.path; - this.start = options.start; + this.start = options.start || 0; this.mtime = options.mtime; } diff --git a/test.js b/test.js index b6cf1a8..a38c8fe 100644 --- a/test.js +++ b/test.js @@ -163,6 +163,15 @@ test('Reading after modified should fail', async t => { t.is(error.name, 'NotReadableError'); }); +test('Reading from the stream created by blobFrom', async t => { + const blob = blobFrom('./LICENSE'); + const expected = await fs.promises.readFile('./LICENSE', 'utf-8'); + + const actual = await getStream(blob.stream()); + + t.is(actual, expected); +}); + test('Blob-ish class is an instance of Blob', t => { class File { stream() {}