From c4ef1e38d169169f6d3f693a9f3f20de02612d7c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 23 Sep 2022 21:20:56 -0400 Subject: [PATCH] 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. --- lib/internal/fs/utils.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 20d5761376d3ee..1e2bdbcd8823a6 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -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); } });