From 860374fdab25fce3161ee835be0e141a341b9b9b Mon Sep 17 00:00:00 2001 From: Cashew <52880648+Scrub1492@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:41:35 +0700 Subject: switch updates (#459) * switch updates * revert to if-else * revert to if-else * remove empty default --- dev/util.js | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'dev') diff --git a/dev/util.js b/dev/util.js index 542ad6a2..731b5456 100644 --- a/dev/util.js +++ b/dev/util.js @@ -45,25 +45,44 @@ export function getArgs(args, argMap) { } const target = argMap.get(key); - if (typeof target === 'boolean') { - argMap.set(key, true); - key = null; - } else if (typeof target === 'number') { - argMap.set(key, target + 1); - key = null; - } else if (target === null || typeof target === 'string') { - if (!onKey) { - argMap.set(key, arg); + + switch (typeof target) { + case 'boolean': + argMap.set(key, true); key = null; - } - } else if (Array.isArray(target)) { - if (!onKey) { - target.push(arg); + break; + case 'number': + argMap.set(key, target + 1); key = null; - } - } else { - console.error(`Unknown argument: ${arg}`); - key = null; + break; + case 'string': + if (!onKey) { + argMap.set(key, arg); + key = null; + } + break; + case 'object': + if (target === null) { + if (!onKey) { + argMap.set(key, arg); + key = null; + } + return argMap; + } else if (Array.isArray(target)) { + if (!onKey) { + target.push(arg); + key = null; + } + return argMap; + } else { + console.error(`Unknown argument: ${arg}`); + key = null; + } + break; + default: + console.error(`Unknown argument: ${arg}`); + key = null; + break; } } -- cgit v1.2.3