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 <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Kohei Ueno <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
cjihrig committed Sep 29, 2022
1 parent df92b3c commit 1b97188
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,17 +884,15 @@ const validateStringAfterArrayBufferView = hideStackFrames((buffer, name) => {

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 1b97188

Please sign in to comment.