Skip to content

Commit 696f8f0

Browse files
committed
benchmark: allow boolean option values
Change createBenchmark to also accept booleans.
1 parent 6322071 commit 696f8f0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

benchmark/common.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ class Benchmark {
118118
const [, key, value] = match;
119119
if (configs[key] !== undefined) {
120120
cliOptions[key] ||= [];
121-
cliOptions[key].push(
122-
// Infer the type from the config object and parse accordingly
123-
typeof configs[key][0] === 'number' ? +value : value,
124-
);
121+
const configType = typeof configs[key][0];
122+
const configValue = configType === 'number' ? +value : configType === 'boolean' ? value === 'true' : value;
123+
cliOptions[key].push(configValue);
125124
} else {
126125
extraOptions[key] = value;
127126
}
@@ -141,7 +140,7 @@ class Benchmark {
141140
const values = options[key];
142141

143142
for (const value of values) {
144-
if (typeof value !== 'number' && typeof value !== 'string') {
143+
if (typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
145144
throw new TypeError(
146145
`configuration "${key}" had type ${typeof value}`);
147146
}

0 commit comments

Comments
 (0)