diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2020-03-10 16:08:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 12:08:58 -0400 |
commit | 6443e4aed16868c17111a56634aa733211430f46 (patch) | |
tree | 8ecbe4d75592fcc78a147b4d69fb61530a0ca2f8 /std | |
parent | fbc4731256a698c07d0d842575d3678d7dc58715 (diff) |
refactor: Cleanup options object parameters (#4296)
Diffstat (limited to 'std')
-rw-r--r-- | std/flags/mod.ts | 16 | ||||
-rw-r--r-- | std/fs/move.ts | 8 | ||||
-rw-r--r-- | std/testing/bench.ts | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/std/flags/mod.ts b/std/flags/mod.ts index 59cae5d15..18727a665 100644 --- a/std/flags/mod.ts +++ b/std/flags/mod.ts @@ -27,31 +27,31 @@ export interface ArgParsingOptions { * * Defaults to `false`. */ - "--": boolean; + "--"?: boolean; /** An object mapping string names to strings or arrays of string argument * names to use as aliases */ - alias: Record<string, string | string[]>; + alias?: Record<string, string | string[]>; /** A boolean, string or array of strings to always treat as booleans. If * `true` will treat all double hyphenated arguments without equal signs as * `boolean` (e.g. affects `--foo`, not `-f` or `--foo=bar`) */ - boolean: boolean | string | string[]; + boolean?: boolean | string | string[]; /** An object mapping string argument names to default values. */ - default: Record<string, unknown>; + default?: Record<string, unknown>; /** When `true`, populate the result `_` with everything after the first * non-option. */ - stopEarly: boolean; + stopEarly?: boolean; /** A string or array of strings argument names to always treat as strings. */ - string: string | string[]; + string?: string | string[]; /** A function which is invoked with a command line parameter not defined in * the `options` configuration object. If the function returns `false`, the * unknown option is not added to `parsedArgs`. */ - unknown: (i: unknown) => unknown; + unknown?: (i: unknown) => unknown; } interface Flags { @@ -108,7 +108,7 @@ export function parse( stopEarly = false, string = [], unknown = (i: unknown): unknown => i - }: Partial<ArgParsingOptions> = {} + }: ArgParsingOptions = {} ): Args { const flags: Flags = { bools: {}, diff --git a/std/fs/move.ts b/std/fs/move.ts index e87d59c6e..48b1ef5f2 100644 --- a/std/fs/move.ts +++ b/std/fs/move.ts @@ -10,7 +10,7 @@ interface MoveOptions { export async function move( src: string, dest: string, - options?: MoveOptions + { overwrite = false }: MoveOptions = {} ): Promise<void> { const srcStat = await Deno.stat(src); @@ -20,7 +20,7 @@ export async function move( ); } - if (options && options.overwrite) { + if (overwrite) { await Deno.remove(dest, { recursive: true }); await Deno.rename(src, dest); } else { @@ -37,7 +37,7 @@ export async function move( export function moveSync( src: string, dest: string, - options?: MoveOptions + { overwrite = false }: MoveOptions = {} ): void { const srcStat = Deno.statSync(src); @@ -47,7 +47,7 @@ export function moveSync( ); } - if (options && options.overwrite) { + if (overwrite) { Deno.removeSync(dest, { recursive: true }); Deno.renameSync(src, dest); } else { diff --git a/std/testing/bench.ts b/std/testing/bench.ts index c76c1bd7c..5cec3ea39 100644 --- a/std/testing/bench.ts +++ b/std/testing/bench.ts @@ -171,7 +171,7 @@ export async function runBenchmarks({ /** Runs specified benchmarks if the enclosing script is main. */ export async function runIfMain( meta: ImportMeta, - opts?: BenchmarkRunOptions + opts: BenchmarkRunOptions = {} ): Promise<void> { if (meta.main) { return runBenchmarks(opts); |