diff --git a/.github/workflows/ghostbuster.yml b/.github/workflows/ghostbuster.yml index d27d116b634ad8..757cb932ac6f22 100644 --- a/.github/workflows/ghostbuster.yml +++ b/.github/workflows/ghostbuster.yml @@ -47,7 +47,7 @@ jobs: fi - if: ${{ inputs.skipPR != 'true' }} - uses: peter-evans/create-pull-request@v4.0.3 + uses: peter-evans/create-pull-request@v4.0.4 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Remove contributors with deleted accounts #no-publishing-comment" diff --git a/types/math-expression-evaluator/index.d.ts b/types/math-expression-evaluator/index.d.ts index 61ac6bdb175758..c04409995b5779 100644 --- a/types/math-expression-evaluator/index.d.ts +++ b/types/math-expression-evaluator/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for math-expression-evaluator 1.2 +// Type definitions for math-expression-evaluator 1.3 // Project: https://github.com/bugwheels94/math-expression-evaluator // Definitions by: DefinitelyTyped +// Definitions by: Adam Zerella // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Token { @@ -9,13 +10,36 @@ interface Token { value?: string|((a: number, b?: number) => number) | undefined; show: string; preced?: number | undefined; + numberOfArguments?: number; } +type TokenName = + | 'FUNCTION_WITH_ONE_ARG' + | 'NUMBER' + | 'BINARY_OPERATOR_HIGH_PRECENDENCE' + | 'CONSTANT' + | 'OPENING_PARENTHESIS' + | 'CLOSING_PARENTHESIS' + | 'DECIMAL' + | 'POSTFIX_FUNCTION_WITH_ONE_ARG' + | 'FUNCTION_WITH_N_ARGS' + | 'BINARY_OPERATOR_LOW_PRECENDENCE' + | 'BINARY_OPERATOR_PERMUTATION' + | 'COMMA' + | 'EVALUATED_FUNCTION' + | 'EVALUATED_FUNCTION_PARAMETER' + | 'SPACE'; + +type TokenTypes = { + [K in TokenName]: number; +}; + declare class Mexp { static lex(inp: string, tokens?: Token[]): Mexp; formulaEval(): Mexp; toPostfix(): Mexp; postfixEval(pair?: object): number|string; + static tokenTypes: TokenTypes; static eval(exp: string, tokens?: Token[], pair?: object): string; static eval(exp: string, mexp?: object): string; static addToken(tokens: Token[]): void; diff --git a/types/math-expression-evaluator/math-expression-evaluator-tests.ts b/types/math-expression-evaluator/math-expression-evaluator-tests.ts index 5af0a9d761bc06..514f387e8dcbc2 100644 --- a/types/math-expression-evaluator/math-expression-evaluator-tests.ts +++ b/types/math-expression-evaluator/math-expression-evaluator-tests.ts @@ -30,6 +30,17 @@ Mexp.addToken([{ preced: 11, token: "mexp" }]); + +Mexp.addToken([{ + type: Mexp.tokenTypes.FUNCTION_WITH_N_ARGS, + token: 'maxof5', + show: 'maxof5', + numberOfArguments: 5, + value: function (a, b) { + return Math.max.apply(Math, [a, b]) + }, +}]); + Mexp.lex("mexp3").toPostfix().postfixEval(); Mexp.lex('mexp3').toPostfix();