mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
benchmark: allow boolean option values
Change createBenchmark to also accept booleans. PR-URL: https://github.com/nodejs/node/pull/60129 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
13073a9b40
commit
7b7004a0ed
1 file changed
+4
-5
+4
-5
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user