From 91127c91cd1d22a98fbf9d66f05fc2155c07c3ff Mon Sep 17 00:00:00 2001 From: SeokhunEom Date: Sun, 14 Dec 2025 20:52:44 +0900 Subject: [PATCH] benchmark: allow boolean option values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change createBenchmark to also accept booleans. PR-URL: https://github.com/nodejs/node/pull/60129 Reviewed-By: Rafael Gonzaga Reviewed-By: Benjamin Gruenbaum Reviewed-By: Gürgün Dayıoğlu --- benchmark/common.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/benchmark/common.js b/benchmark/common.js index bc8695df09d..8443da40d79 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -118,10 +118,9 @@ class Benchmark { const [, key, value] = match; if (configs[key] !== undefined) { cliOptions[key] ||= []; - cliOptions[key].push( - // Infer the type from the config object and parse accordingly - typeof configs[key][0] === 'number' ? +value : value, - ); + const configType = typeof configs[key][0]; + const configValue = configType === 'number' ? +value : configType === 'boolean' ? value === 'true' : value; + cliOptions[key].push(configValue); } else { extraOptions[key] = value; } @@ -141,7 +140,7 @@ class Benchmark { const values = options[key]; for (const value of values) { - if (typeof value !== 'number' && typeof value !== 'string') { + if (typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') { throw new TypeError( `configuration "${key}" had type ${typeof value}`); }