Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

[ISSUE #2554] Throw if start type is not number #2567

Closed
Closed
Changes from all commits
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
5 changes: 5 additions & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,13 @@ var ReadStream = fs.ReadStream = function(path, options) {
if (this.encoding) this.setEncoding(this.encoding);

if (this.start !== undefined) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to kill this conditional now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite. this.start is allowed to be undefined

if ('number' !== typeof this.start) {
throw TypeError("'start' must be a Number (not a string containing a number)");
}
if (this.end === undefined) {
this.end = Infinity;
} else if ('number' !== typeof this.end) {
throw TypeError("'end' must be a Number (not a string containing a number)");
}

if (this.start > this.end) {
Expand Down