From 2a9ac06f978f78e82f6d701dd99800b78ec0f31b Mon Sep 17 00:00:00 2001 From: Amit Dhamu Date: Wed, 4 May 2022 20:07:27 +0100 Subject: [PATCH] Arge return type --- package.json | 2 +- src/index.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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