diff --git a/package.json b/package.json index 1d4dabb..1a5d18d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arge", - "version": "1.1.3", + "version": "1.1.4", "description": "A simple utility to parse command line arguments and flags", "keywords": [ "argv", diff --git a/src/index.ts b/src/index.ts index 62e3c41..d0b6e55 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,13 +3,15 @@ interface Options { camelCaseKeys?: boolean } +type Value = string | boolean | number | string[] + const toArray = (value: string, delimiter: string) => value .split(delimiter) .map(v => v.trim()) .filter(v => v) -const parse = (value: string): string | boolean | number | string[] => { +const parse = (value: string): Value => { if (['true', 'false', true, false].includes(value)) { return JSON.parse(value) } @@ -35,7 +37,7 @@ export const arge = ( isArgv: true, camelCaseKeys: true, } -) => +): Record => (options.isArgv !== false ? args.filter((_, index) => index > 1) : args