Skip to content

Commit

Permalink
fix end is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanaasagi committed Jul 28, 2023
1 parent f93b858 commit 6099f88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/js/node/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,14 @@ ReadStream = (function (InternalReadStream) {
chunk = chunk.slice(-n);
var [_, ...rest] = arguments;
this.pos = this.bytesRead;
if (this.end && this.bytesRead >= this.end) {
if (this.end !== undefined && this.bytesRead > this.end) {
chunk = chunk.slice(0, this.end - this.start + 1);
}
return super.push(chunk, ...rest);
}
var end = this.end;
// This is multi-chunk read case where we go passed the end of the what we want to read in the last chunk
if (end && this.bytesRead >= end) {
if (end !== undefined && this.bytesRead > end) {
chunk = chunk.slice(0, end - currPos + 1);
var [_, ...rest] = arguments;
this.pos = this.bytesRead;
Expand Down
4 changes: 2 additions & 2 deletions src/js/out/modules/node/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ ReadStream = function(InternalReadStream) {
var n = this.bytesRead - currPos;
chunk = chunk.slice(-n);
var [_, ...rest] = arguments;
if (this.pos = this.bytesRead, this.end && this.bytesRead >= this.end)
if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)
chunk = chunk.slice(0, this.end - this.start + 1);
return super.push(chunk, ...rest);
}
var end = this.end;
if (end && this.bytesRead >= end) {
if (end !== void 0 && this.bytesRead > end) {
chunk = chunk.slice(0, end - currPos + 1);
var [_, ...rest] = arguments;
return this.pos = this.bytesRead, super.push(chunk, ...rest);
Expand Down

0 comments on commit 6099f88

Please sign in to comment.