id
int64
0
3.78k
code
stringlengths
13
37.9k
declarations
stringlengths
16
64.6k
2,700
optimizeNames(names: UsedNames, constants: Constants): this | undefined { if (!super.optimizeNames(names, constants)) return this.iterable = optimizeExpr(this.iterable, names, constants) return this }
type Constants = Record<string, SafeExpr | undefined>
2,701
optimizeNames(names: UsedNames, constants: Constants): this | undefined { if (!super.optimizeNames(names, constants)) return this.iterable = optimizeExpr(this.iterable, names, constants) return this }
type UsedNames = Record<string, number | undefined>
2,702
constructor(public name: Name, public args: Code, public async?: boolean) { super() }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,703
constructor(public name: Name, public args: Code, public async?: boolean) { super() }
type Code = _Code | Name
2,704
render(opts: CGOptions): string { const _async = this.async ? "async " : "" return `${_async}function ${this.name}(${this.args})` + super.render(opts) }
interface CGOptions extends CodeGenOptions { _n: "\n" | "" }
2,705
render(opts: CGOptions): string { return "return " + super.render(opts) }
interface CGOptions extends CodeGenOptions { _n: "\n" | "" }
2,706
render(opts: CGOptions): string { let code = "try" + super.render(opts) if (this.catch) code += this.catch.render(opts) if (this.finally) code += this.finally.render(opts) return code }
interface CGOptions extends CodeGenOptions { _n: "\n" | "" }
2,707
optimizeNames(names: UsedNames, constants: Constants): this { super.optimizeNames(names, constants) this.catch?.optimizeNames(names, constants) this.finally?.optimizeNames(names, constants) return this }
type Constants = Record<string, SafeExpr | undefined>
2,708
optimizeNames(names: UsedNames, constants: Constants): this { super.optimizeNames(names, constants) this.catch?.optimizeNames(names, constants) this.finally?.optimizeNames(names, constants) return this }
type UsedNames = Record<string, number | undefined>
2,709
constructor(readonly error: Name) { super() }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,710
render(opts: CGOptions): string { return `catch(${this.error})` + super.render(opts) }
interface CGOptions extends CodeGenOptions { _n: "\n" | "" }
2,711
render(opts: CGOptions): string { return "finally" + super.render(opts) }
interface CGOptions extends CodeGenOptions { _n: "\n" | "" }
2,712
constructor(extScope: ValueScope, opts: CodeGenOptions = {}) { this.opts = {...opts, _n: opts.lines ? "\n" : ""} this._extScope = extScope this._scope = new Scope({parent: extScope}) this._nodes = [new Root()] }
class ValueScope extends Scope { protected readonly _values: ScopeValues = {} protected readonly _scope: ScopeStore readonly opts: VSOptions constructor(opts: ValueScopeOptions) { super(opts) this._scope = opts.scope this.opts = {...opts, _n: opts.lines ? line : nil} } get(): ScopeStore { ...
2,713
constructor(extScope: ValueScope, opts: CodeGenOptions = {}) { this.opts = {...opts, _n: opts.lines ? "\n" : ""} this._extScope = extScope this._scope = new Scope({parent: extScope}) this._nodes = [new Root()] }
interface CodeGenOptions { es5?: boolean lines?: boolean ownProperties?: boolean }
2,714
scopeRefs(scopeName: Name): Code { return this._extScope.scopeRefs(scopeName, this._values) }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,715
private _def( varKind: Name, nameOrPrefix: Name | string, rhs?: SafeExpr, constant?: boolean ): Name { const name = this._scope.toName(nameOrPrefix) if (rhs !== undefined && constant) this._constants[name.str] = rhs this._leafNode(new Def(varKind, name, rhs)) return name }
type SafeExpr = Code | number | boolean | null
2,716
private _def( varKind: Name, nameOrPrefix: Name | string, rhs?: SafeExpr, constant?: boolean ): Name { const name = this._scope.toName(nameOrPrefix) if (rhs !== undefined && constant) this._constants[name.str] = rhs this._leafNode(new Def(varKind, name, rhs)) return name }
type SafeExpr = Code | number | boolean | null
2,717
private _def( varKind: Name, nameOrPrefix: Name | string, rhs?: SafeExpr, constant?: boolean ): Name { const name = this._scope.toName(nameOrPrefix) if (rhs !== undefined && constant) this._constants[name.str] = rhs this._leafNode(new Def(varKind, name, rhs)) return name }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,718
assign(lhs: Code, rhs: SafeExpr, sideEffects?: boolean): CodeGen { return this._leafNode(new Assign(lhs, rhs, sideEffects)) }
type SafeExpr = Code | number | boolean | null
2,719
assign(lhs: Code, rhs: SafeExpr, sideEffects?: boolean): CodeGen { return this._leafNode(new Assign(lhs, rhs, sideEffects)) }
type SafeExpr = Code | number | boolean | null
2,720
assign(lhs: Code, rhs: SafeExpr, sideEffects?: boolean): CodeGen { return this._leafNode(new Assign(lhs, rhs, sideEffects)) }
type Code = _Code | Name
2,721
add(lhs: Code, rhs: SafeExpr): CodeGen { return this._leafNode(new AssignOp(lhs, operators.ADD, rhs)) }
type SafeExpr = Code | number | boolean | null
2,722
add(lhs: Code, rhs: SafeExpr): CodeGen { return this._leafNode(new AssignOp(lhs, operators.ADD, rhs)) }
type SafeExpr = Code | number | boolean | null
2,723
add(lhs: Code, rhs: SafeExpr): CodeGen { return this._leafNode(new AssignOp(lhs, operators.ADD, rhs)) }
type Code = _Code | Name
2,724
private _for(node: For, forBody?: Block): CodeGen { this._blockNode(node) if (forBody) this.code(forBody).endFor() return this }
type Block = Code | (() => void)
2,725
for(iteration: Code, forBody?: Block): CodeGen { return this._for(new ForLoop(iteration), forBody) }
type Block = Code | (() => void)
2,726
for(iteration: Code, forBody?: Block): CodeGen { return this._for(new ForLoop(iteration), forBody) }
type Code = _Code | Name
2,727
(index: Name) => void
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,728
(item: Name) => void
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,729
label(label: Name): CodeGen { return this._leafNode(new Label(label)) }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,730
break(label?: Code): CodeGen { return this._leafNode(new Break(label)) }
type Code = _Code | Name
2,731
try(tryBody: Block, catchCode?: (e: Name) => void, finallyCode?: Block): CodeGen { if (!catchCode && !finallyCode) throw new Error('CodeGen: "try" without "catch" and "finally"') const node = new Try() this._blockNode(node) this.code(tryBody) if (catchCode) { const error = this.name("e") ...
type Block = Code | (() => void)
2,732
try(tryBody: Block, catchCode?: (e: Name) => void, finallyCode?: Block): CodeGen { if (!catchCode && !finallyCode) throw new Error('CodeGen: "try" without "catch" and "finally"') const node = new Try() this._blockNode(node) this.code(tryBody) if (catchCode) { const error = this.name("e") ...
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,733
(e: Name) => void
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,734
throw(error: Code): CodeGen { return this._leafNode(new Throw(error)) }
type Code = _Code | Name
2,735
block(body?: Block, nodeCount?: number): CodeGen { this._blockStarts.push(this._nodes.length) if (body) this.code(body).endBlock(nodeCount) return this }
type Block = Code | (() => void)
2,736
func(name: Name, args: Code = nil, async?: boolean, funcBody?: Block): CodeGen { this._blockNode(new Func(name, args, async)) if (funcBody) this.code(funcBody).endFunc() return this }
type Block = Code | (() => void)
2,737
func(name: Name, args: Code = nil, async?: boolean, funcBody?: Block): CodeGen { this._blockNode(new Func(name, args, async)) if (funcBody) this.code(funcBody).endFunc() return this }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,738
func(name: Name, args: Code = nil, async?: boolean, funcBody?: Block): CodeGen { this._blockNode(new Func(name, args, async)) if (funcBody) this.code(funcBody).endFunc() return this }
type Code = _Code | Name
2,739
private _leafNode(node: LeafNode): CodeGen { this._currNode.nodes.push(node) return this }
type LeafNode = Def | Assign | Label | Break | Throw | AnyCode
2,740
private _blockNode(node: StartBlockNode): void { this._currNode.nodes.push(node) this._nodes.push(node) }
type StartBlockNode = If | For | Func | Return | Try
2,741
private _endBlockNode(N1: EndBlockNodeType, N2?: EndBlockNodeType): CodeGen { const n = this._currNode if (n instanceof N1 || (N2 && n instanceof N2)) { this._nodes.pop() return this } throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`) }
type EndBlockNodeType = | typeof If | typeof Else | typeof For | typeof Func | typeof Return | typeof Catch | typeof Finally
2,742
function addNames(names: UsedNames, from: UsedNames): UsedNames { for (const n in from) names[n] = (names[n] || 0) + (from[n] || 0) return names }
type UsedNames = Record<string, number | undefined>
2,743
function addExprNames(names: UsedNames, from: SafeExpr): UsedNames { return from instanceof _CodeOrName ? addNames(names, from.names) : names }
type SafeExpr = Code | number | boolean | null
2,744
function addExprNames(names: UsedNames, from: SafeExpr): UsedNames { return from instanceof _CodeOrName ? addNames(names, from.names) : names }
type SafeExpr = Code | number | boolean | null
2,745
function addExprNames(names: UsedNames, from: SafeExpr): UsedNames { return from instanceof _CodeOrName ? addNames(names, from.names) : names }
type UsedNames = Record<string, number | undefined>
2,746
function optimizeExpr<T extends SafeExpr | Code>(expr: T, names: UsedNames, constants: Constants): T
type Constants = Record<string, SafeExpr | undefined>
2,747
function optimizeExpr<T extends SafeExpr | Code>(expr: T, names: UsedNames, constants: Constants): T
type UsedNames = Record<string, number | undefined>
2,748
function optimizeExpr(expr: SafeExpr, names: UsedNames, constants: Constants): SafeExpr { if (expr instanceof Name) return replaceName(expr) if (!canOptimize(expr)) return expr return new _Code( expr._items.reduce((items: CodeItem[], c: SafeExpr | string) => { if (c instanceof Name) c = replaceName(c) ...
type SafeExpr = Code | number | boolean | null
2,749
function optimizeExpr(expr: SafeExpr, names: UsedNames, constants: Constants): SafeExpr { if (expr instanceof Name) return replaceName(expr) if (!canOptimize(expr)) return expr return new _Code( expr._items.reduce((items: CodeItem[], c: SafeExpr | string) => { if (c instanceof Name) c = replaceName(c) ...
type SafeExpr = Code | number | boolean | null
2,750
function optimizeExpr(expr: SafeExpr, names: UsedNames, constants: Constants): SafeExpr { if (expr instanceof Name) return replaceName(expr) if (!canOptimize(expr)) return expr return new _Code( expr._items.reduce((items: CodeItem[], c: SafeExpr | string) => { if (c instanceof Name) c = replaceName(c) ...
type UsedNames = Record<string, number | undefined>
2,751
function optimizeExpr(expr: SafeExpr, names: UsedNames, constants: Constants): SafeExpr { if (expr instanceof Name) return replaceName(expr) if (!canOptimize(expr)) return expr return new _Code( expr._items.reduce((items: CodeItem[], c: SafeExpr | string) => { if (c instanceof Name) c = replaceName(c) ...
type Constants = Record<string, SafeExpr | undefined>
2,752
function replaceName(n: Name): SafeExpr { const c = constants[n.str] if (c === undefined || names[n.str] !== 1) return n delete names[n.str] return c }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,753
function canOptimize(e: SafeExpr): e is _Code { return ( e instanceof _Code && e._items.some( (c) => c instanceof Name && names[c.str] === 1 && constants[c.str] !== undefined ) ) }
type SafeExpr = Code | number | boolean | null
2,754
function canOptimize(e: SafeExpr): e is _Code { return ( e instanceof _Code && e._items.some( (c) => c instanceof Name && names[c.str] === 1 && constants[c.str] !== undefined ) ) }
type SafeExpr = Code | number | boolean | null
2,755
function subtractNames(names: UsedNames, from: UsedNames): void { for (const n in from) names[n] = (names[n] || 0) - (from[n] || 0) }
type UsedNames = Record<string, number | undefined>
2,756
(x: Code, y: Code) => Code
type Code = _Code | Name
2,757
function mappend(op: Code): MAppend { return (x, y) => (x === nil ? y : y === nil ? x : _`${par(x)} ${op} ${par(y)}`) }
type Code = _Code | Name
2,758
function par(x: Code): Code { return x instanceof Name ? x : _`(${x})` }
type Code = _Code | Name
2,759
constructor(name: ValueScopeName) { super(`CodeGen: "code" for ${name} not defined`) this.value = name.value }
class ValueScopeName extends Name { readonly prefix: string value?: NameValue scopePath?: Code constructor(prefix: string, nameStr: string) { super(nameStr) this.prefix = prefix } setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${...
2,760
constructor({prefixes, parent}: ScopeOptions = {}) { this._prefixes = prefixes this._parent = parent }
interface ScopeOptions { prefixes?: Set<string> parent?: Scope }
2,761
setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${new Name(property)}[${itemIndex}]` }
interface NameValue { ref: ValueReference // this is the reference to any value that can be referred to from generated code via `globals` var in the closure key?: unknown // any key to identify a global to avoid duplicates, if not passed ref is used code?: Code // this is the code creating the value needed for st...
2,762
setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${new Name(property)}[${itemIndex}]` }
interface ScopePath { property: string itemIndex: number }
2,763
constructor(opts: ValueScopeOptions) { super(opts) this._scope = opts.scope this.opts = {...opts, _n: opts.lines ? line : nil} }
interface ValueScopeOptions extends ScopeOptions { scope: ScopeStore es5?: boolean lines?: boolean }
2,764
scopeRefs(scopeName: Name, values: ScopeValues | ScopeValueSets = this._values): Code { return this._reduceValues(values, (name: ValueScopeName) => { if (name.scopePath === undefined) throw new Error(`CodeGen: name "${name}" has no value`) return _`${scopeName}${name.scopePath}` }) }
class Name extends _CodeOrName { readonly str: string constructor(s: string) { super() if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier") this.str = s } toString(): string { return this.str } emptyStr(): boolean { return false } get names(): UsedN...
2,765
(name: ValueScopeName) => { if (name.scopePath === undefined) throw new Error(`CodeGen: name "${name}" has no value`) return _`${scopeName}${name.scopePath}` }
class ValueScopeName extends Name { readonly prefix: string value?: NameValue scopePath?: Code constructor(prefix: string, nameStr: string) { super(nameStr) this.prefix = prefix } setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${...
2,766
(n: ValueScopeName) => Code | undefined
class ValueScopeName extends Name { readonly prefix: string value?: NameValue scopePath?: Code constructor(prefix: string, nameStr: string) { super(nameStr) this.prefix = prefix } setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${...
2,767
(name: ValueScopeName) => { if (name.value === undefined) throw new Error(`CodeGen: name "${name}" has no value`) return name.value.code }
class ValueScopeName extends Name { readonly prefix: string value?: NameValue scopePath?: Code constructor(prefix: string, nameStr: string) { super(nameStr) this.prefix = prefix } setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${...
2,768
(name: ValueScopeName) => { if (nameSet.has(name)) return nameSet.set(name, UsedValueState.Started) let c = valueCode(name) if (c) { const def = this.opts.es5 ? varKinds.var : varKinds.const code = _`${code}${def} ${name} = ${c};${this.opts._n}` } else if ((c ...
class ValueScopeName extends Name { readonly prefix: string value?: NameValue scopePath?: Code constructor(prefix: string, nameStr: string) { super(nameStr) this.prefix = prefix } setValue(value: NameValue, {property, itemIndex}: ScopePath): void { this.value = value this.scopePath = _`.${...
2,769
function Parser (args: ArgsInput, opts?: Partial<Options>): Arguments { const result = parser.parse(args.slice(), opts) return result.argv }
type ArgsInput = string | any[];
2,770
function (args: ArgsInput, opts?: Partial<Options>): DetailedArguments { return parser.parse(args.slice(), opts) }
type ArgsInput = string | any[];
2,771
(args: ArgsInput, opts?: Partial<Options>): Arguments
type ArgsInput = string | any[];
2,772
detailed(args: ArgsInput, opts?: Partial<Options>): DetailedArguments
type ArgsInput = string | any[];
2,773
constructor (_mixin: YargsParserMixin) { mixin = _mixin }
interface YargsParserMixin { cwd: Function; format: Function; normalize: Function; require: Function; resolve: Function; env: Function; }
2,774
parse (argsInput: ArgsInput, options?: Partial<Options>): DetailedArguments { const opts: Partial<Options> = Object.assign({ alias: undefined, array: undefined, boolean: undefined, config: undefined, configObjects: undefined, configuration: undefined, coerce: undefined, ...
type ArgsInput = string | any[];
2,775
function setConfig (argv: Arguments): void { const configLookup = Object.create(null) // expand defaults/aliases, in-case any happen to reference // the config.json file. applyDefaultsAndAliases(configLookup, flags.aliases, defaults) Object.keys(flags.configs).forEach(function (configKey...
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,776
function applyEnvVars (argv: Arguments, configOnly: boolean): void { if (typeof envPrefix === 'undefined') return const prefix = typeof envPrefix === 'string' ? envPrefix : '' const env = mixin.env() Object.keys(env).forEach(function (envVar) { if (prefix === '' || envVar.lastIndexOf(pr...
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,777
function applyCoercions (argv: Arguments): void { let coerce: false | CoerceCallback const applied: Set<string> = new Set() Object.keys(argv).forEach(function (key) { if (!applied.has(key)) { // If we haven't already coerced this option via one of its aliases coerce = checkAllAliases...
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,778
function setPlaceholderKeys (argv: Arguments): Arguments { flags.keys.forEach((key) => { // don't set placeholder keys for dot notation options 'foo.bar'. if (~key.indexOf('.')) return if (typeof argv[key] === 'undefined') argv[key] = undefined }) return argv }
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,779
(_err: Error, argv: Arguments, _output: string) => { output = _output; }
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,780
(_err: Error, argv: Arguments, _output: string) => { output = _output; }
interface Arguments { /** The script name or node command */ $0: string; /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,781
(_err: Error, argv: Arguments, _output: string) => { output = _output; }
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,782
async (argv: Arguments) => { await new Promise(resolve => { setTimeout(resolve, 10); }); argv.foo *= 2; }
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,783
async (argv: Arguments) => { await new Promise(resolve => { setTimeout(resolve, 10); }); argv.foo *= 2; }
interface Arguments { /** The script name or node command */ $0: string; /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,784
async (argv: Arguments) => { await new Promise(resolve => { setTimeout(resolve, 10); }); argv.foo *= 2; }
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,785
registerFunction(fn: CompletionFunction): void
type CompletionFunction = | SyncCompletionFunction | AsyncCompletionFunction | FallbackCompletionFunction;
2,786
setParsed(parsed: DetailedArguments): void
interface DetailedArguments extends ParserDetailedArguments { argv: Arguments; aliases: Dictionary<string[]>; }
2,787
setParsed(parsed: DetailedArguments): void
interface DetailedArguments { /** An object representing the parsed value of `args` */ argv: Arguments; /** Populated with an error object if an exception occurred during parsing. */ error: Error | null; /** The inferred list of aliases built by combining lists in opts.alias. */ aliases: Dictionary<string[]...
2,788
constructor( private readonly yargs: YargsInstance, private readonly usage: UsageInstance, private readonly command: CommandInstance, private readonly shim: PlatformShim ) { this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ...
class CommandInstance { shim: PlatformShim; requireCache: Set<string> = new Set(); handlers: Dictionary<CommandHandler> = {}; aliasMap: Dictionary<string> = {}; defaultCommand?: CommandHandler; usage: UsageInstance; globalMiddleware: GlobalMiddleware; validation: ValidationInstance; // Used to cache s...
2,789
constructor( private readonly yargs: YargsInstance, private readonly usage: UsageInstance, private readonly command: CommandInstance, private readonly shim: PlatformShim ) { this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ...
interface UsageInstance { cacheHelpMessage(): void; clearCachedHelpMessage(): void; hasCachedHelpMessage(): boolean; command( cmd: string, description: string | undefined, isDefault: boolean, aliases: string[], deprecated?: boolean ): void; deferY18nLookup(str: string): string; describ...
2,790
constructor( private readonly yargs: YargsInstance, private readonly usage: UsageInstance, private readonly command: CommandInstance, private readonly shim: PlatformShim ) { this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ...
interface PlatformShim { cwd: Function; format: Function; normalize: Function; require: Function; resolve: Function; env: Function; }
2,791
constructor( private readonly yargs: YargsInstance, private readonly usage: UsageInstance, private readonly command: CommandInstance, private readonly shim: PlatformShim ) { this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ...
interface PlatformShim { assert: { notStrictEqual: ( expected: any, observed: any, message?: string | Error ) => void; strictEqual: ( expected: any, observed: any, message?: string | Error ) => void; }; findUp: ( startDir: string, fn: (dir: string[], nam...
2,792
constructor( private readonly yargs: YargsInstance, private readonly usage: UsageInstance, private readonly command: CommandInstance, private readonly shim: PlatformShim ) { this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ...
class YargsInstance { $0: string; argv?: Arguments; customScriptName = false; parsed: DetailedArguments | false = false; #command: CommandInstance; #cwd: string; // use context object to keep track of resets, subcommand execution, etc., // submodules should modify and check the state of context as nece...
2,793
(argv: Arguments) => this.customCompletion(args, argv, current, done)
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,794
(argv: Arguments) => this.customCompletion(args, argv, current, done)
interface Arguments { /** The script name or node command */ $0: string; /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,795
(argv: Arguments) => this.customCompletion(args, argv, current, done)
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,796
(argv: Arguments) => this.defaultCompletion(args, argv, current, done)
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,797
(argv: Arguments) => this.defaultCompletion(args, argv, current, done)
interface Arguments { /** The script name or node command */ $0: string; /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,798
(argv: Arguments) => this.defaultCompletion(args, argv, current, done)
interface Arguments { /** Non-option arguments */ _: ArgsOutput; /** Arguments after the end-of-options flag `--` */ '--'?: ArgsOutput; /** All remaining options */ [argName: string]: any; }
2,799
registerFunction(fn: CompletionFunction) { this.customCompletionFunction = fn; }
type CompletionFunction = | SyncCompletionFunction | AsyncCompletionFunction | FallbackCompletionFunction;