Skip to content

Fix for the 'start' range of BlobDataItem when reading its stream #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix for the 'start' range of BlobDataItem when reading its stream or …
…slicing.
  • Loading branch information
octet-stream committed Apr 24, 2021
commit 01bbd94b1d29258fadcfe4807b80aa760acb7f95
4 changes: 2 additions & 2 deletions from.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BlobDataItem {
path: this.path,
start,
mtime: this.mtime,
size: end - start
size: start ? end - start : end
});
}

Expand All @@ -45,7 +45,7 @@ class BlobDataItem {

return createReadStream(this.path, {
start: this.start,
end: this.start + this.size - 1
end: (this.start ? this.start + this.size : this.size) - 1
});
}

Expand Down
9 changes: 9 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down