Skip to content

Commit

Permalink
Arge return type
Browse files Browse the repository at this point in the history
  • Loading branch information
adhamu committed May 4, 2022
1 parent 6c35ba2 commit 2a9ac06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -35,7 +37,7 @@ export const arge = (
isArgv: true,
camelCaseKeys: true,
}
) =>
): Record<string, Value> =>
(options.isArgv !== false
? args.filter((_, index) => index > 1)
: args
Expand Down

0 comments on commit 2a9ac06

Please sign in to comment.