From faaed8fbfc4b409987479046b01388df027facea Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 18 Feb 2026 12:42:57 +0000 Subject: [PATCH] perf(index): cache typeof result in `parseOptions` --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 3a365a5..0bb9d80 100644 --- a/src/index.js +++ b/src/index.js @@ -87,8 +87,9 @@ function parseOptions(acceptedOptions, options, version) { // @ts-ignore: Keys are from options, TS cannot infer this const option = options[key]; const acceptedOption = acceptedOptions[key]; + const optionType = typeof option; - if (acceptedOption.type === typeof option) { + if (acceptedOption.type === optionType) { // Skip boolean options if false if (acceptedOption.type !== "boolean" || option) { args.push(acceptedOption.arg); @@ -97,7 +98,7 @@ function parseOptions(acceptedOptions, options, version) { invalidArgs.push( `Invalid value type provided for option '${key}', expected ${ acceptedOption.type - } but received ${typeof option}` + } but received ${optionType}` ); }