Skip to content

Commit

Permalink
fs: don't hard code name in validatePosition()
Browse files Browse the repository at this point in the history
The name of the position being validated by validatePosition()
was not being used. Instead, the string 'position' was being
used everywhere. It worked out because the only call sites were
using the name 'position' as well.

PR-URL: #44767
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
cjihrig authored and danielleadams committed Oct 5, 2022
1 parent f85d347 commit dc6379b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/internal/fs/utils.js
Expand Up @@ -906,17 +906,15 @@ const validatePrimitiveStringAfterArrayBufferView = hideStackFrames((buffer, nam

const validatePosition = hideStackFrames((position, name) => {
if (typeof position === 'number') {
validateInteger(position, 'position');
validateInteger(position, name);
} else if (typeof position === 'bigint') {
if (!(position >= -(2n ** 63n) && position <= 2n ** 63n - 1n)) {
throw new ERR_OUT_OF_RANGE('position',
throw new ERR_OUT_OF_RANGE(name,
`>= ${-(2n ** 63n)} && <= ${2n ** 63n - 1n}`,
position);
}
} else {
throw new ERR_INVALID_ARG_TYPE('position',
['integer', 'bigint'],
position);
throw new ERR_INVALID_ARG_TYPE(name, ['integer', 'bigint'], position);
}
});

Expand Down

0 comments on commit dc6379b

Please sign in to comment.