Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ghostbuster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 25 additions & 1 deletion types/math-expression-evaluator/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/DefinitelyTyped>
// Definitions by: Adam Zerella <https://github.com/azerella>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

interface Token {
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions types/math-expression-evaluator/math-expression-evaluator-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down