Skip to content

Commit a4077ea

Browse files
committed
Resolve nits and fix failures (hopefully)
1 parent 83f478e commit a4077ea

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/fs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,13 +2008,13 @@ function ReadStream(path, options) {
20082008
this.closed = false;
20092009

20102010
if (this.start !== undefined) {
2011-
if (typeof this.start !== 'number' || Number.isNaN(this.start)) {
2012-
throw new ERR_INVALID_ARG_TYPE('start', 'number', this.start);
2011+
if (typeof this.start !== 'number' || !Number.isInteger(this.start)) {
2012+
throw new ERR_INVALID_ARG_TYPE('start', 'integer', this.start);
20132013
}
20142014
if (this.end === undefined) {
20152015
this.end = Infinity;
2016-
} else if (typeof this.end !== 'number' || Number.isNaN(this.end)) {
2017-
throw new ERR_INVALID_ARG_TYPE('end', 'number', this.end);
2016+
} else if (typeof this.end !== 'number' || !Number.isInteger(this.end)) {
2017+
throw new ERR_INVALID_ARG_TYPE('end', 'integer', this.end);
20182018
}
20192019

20202020
if (this.start > this.end) {
@@ -2028,8 +2028,10 @@ function ReadStream(path, options) {
20282028
// Backwards compatibility: Make sure `end` is a number regardless of `start`.
20292029
// TODO(addaleax): Make the above typecheck not depend on `start` instead.
20302030
// (That is a semver-major change).
2031-
if (typeof this.end !== 'number' || Number.isNaN(this.end))
2031+
if (typeof this.end !== 'number')
20322032
this.end = Infinity;
2033+
else if (!Number.isInteger(this.end))
2034+
throw new ERR_INVALID_ARG_TYPE('end', 'integer', this.end);
20332035

20342036
if (typeof this.fd !== 'number')
20352037
this.open();

test/parallel/test-fs-read-stream-throw-type-error.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const createReadStreamErr = (path, opt) => {
2222
{
2323
code: 'ERR_INVALID_ARG_TYPE',
2424
type: TypeError
25-
}
26-
);
25+
});
2726
};
2827

2928
createReadStreamErr(example, 123);

0 commit comments

Comments
 (0)