From dc6379bdc205de436c327a123ba58e2afa4e7e0c 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() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Daeyeon Jeong Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Kohei Ueno Reviewed-By: Tobias Nießen Reviewed-By: Trivikram Kamat --- 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 d1e521426f0bd3..9ff9d46b1bc75b 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -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); } });