Skip to content

Commit

Permalink
Revert "fs: fix options.end of fs.ReadStream()"
Browse files Browse the repository at this point in the history
This reverts commit df038ad.

Some people were relying on the behavior of this.start being able to be
undefined, whereas after the change it is being set to 0.

Fixes: #19240
Refs: #18121
  • Loading branch information
MylesBorins committed Mar 13, 2018
1 parent fe71f19 commit d579aed
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
3 changes: 1 addition & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1919,8 +1919,7 @@ function ReadStream(path, options) {
this.flags = options.flags === undefined ? 'r' : options.flags;
this.mode = options.mode === undefined ? 0o666 : options.mode;

this.start = typeof this.fd !== 'number' && options.start === undefined ?
0 : options.start;
this.start = options.start;
this.end = options.end;
this.autoClose = options.autoClose === undefined ? true : options.autoClose;
this.pos = undefined;
Expand Down
14 changes: 0 additions & 14 deletions test/parallel/test-fs-read-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ stream.on('end', function() {
assert.strictEqual('x', stream.data);
});

{
// Verify that end works when start is not specified.
const stream = new fs.createReadStream(rangeFile, { end: 1 });
stream.data = '';

stream.on('data', function(chunk) {
stream.data += chunk;
});

stream.on('end', common.mustCall(function() {
assert.strictEqual('xy', stream.data);
}));
}

// pause and then resume immediately.
const pauseRes = fs.createReadStream(rangeFile);
pauseRes.pause();
Expand Down

0 comments on commit d579aed

Please sign in to comment.