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.
  • Loading branch information
cjihrig committed Sep 28, 2022
1 parent 3d49437 commit 2cf4229
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/internal/fs/utils.js
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 2cf4229

Please sign in to comment.