fs: don't hard code name in validatePosition()

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
cjihrig authored and Juan José Arboleda committed 2022-10-11 14:45:29 -05:00
1 parent 25e6f48e4a
commit 14ec52b949
1 file changed
+3 -5
+3 -5
View File
@@ -903,17 +903,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);
}
});