Skip to content

Commit bfed77e

Browse files
committed
benchmark: allow boolean option values
Change createBenchmark to also accept booleans.
1 parent 0c1fb98 commit bfed77e

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
@@ -117,10 +117,9 @@ class Benchmark {
117117
const [, key, value] = match;
118118
if (configs[key] !== undefined) {
119119
cliOptions[key] ||= [];
120-
cliOptions[key].push(
121-
// Infer the type from the config object and parse accordingly
122-
typeof configs[key][0] === 'number' ? +value : value,
123-
);
120+
const configType = typeof configs[key][0];
121+
const configValue = configType === 'number' ? +value : configType === 'boolean' ? value === 'true' : value;
122+
cliOptions[key].push(configValue);
124123
} else {
125124
extraOptions[key] = value;
126125
}
@@ -140,7 +139,7 @@ class Benchmark {
140139
const values = options[key];
141140

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

0 commit comments

Comments
 (0)