mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add type definitions for math-expression-evaluator (#43009)
Co-authored-by: Adam Zerella <adamzerella@users.noreply.github.com>
This commit is contained in:
parent
9582dc2bb7
commit
3cbb889216
24
types/math-expression-evaluator/index.d.ts
vendored
Normal file
24
types/math-expression-evaluator/index.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Type definitions for math-expression-evaluator 1.2
|
||||
// Project: https://github.com/bugwheels94/math-expression-evaluator
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Token {
|
||||
token: string;
|
||||
type: number;
|
||||
value?: string|((a: number, b?: number) => number);
|
||||
show: string;
|
||||
preced?: number;
|
||||
}
|
||||
|
||||
declare class Mexp {
|
||||
static lex(inp: string, tokens?: Token[]): Mexp;
|
||||
formulaEval(): Mexp;
|
||||
toPostfix(): Mexp;
|
||||
postfixEval(pair?: object): number|string;
|
||||
static eval(exp: string, tokens?: Token[], pair?: object): string;
|
||||
static eval(exp: string, mexp?: object): string;
|
||||
static addToken(tokens: Token[]): void;
|
||||
}
|
||||
|
||||
export = Mexp;
|
||||
@ -0,0 +1,36 @@
|
||||
import Mexp = require("math-expression-evaluator");
|
||||
|
||||
Mexp.eval("5*.8");
|
||||
Mexp.eval("5*.8", { mexp: 5 });
|
||||
Mexp.eval("mexp(3)", [{
|
||||
type: 0,
|
||||
show: "mexp(\",value:function(a){return 5*a;}",
|
||||
preced: 11,
|
||||
token: "mexp"
|
||||
}]);
|
||||
Mexp.eval("mexp(3)", [{
|
||||
type: 0,
|
||||
token: "inverse",
|
||||
show: "inverse",
|
||||
value: (a => 1 / a)
|
||||
}]);
|
||||
|
||||
Mexp.addToken([{
|
||||
type: 3,
|
||||
token: "git",
|
||||
show: "git",
|
||||
value: "git"
|
||||
}]);
|
||||
Mexp.eval("mexp*3", { mexp: 5 });
|
||||
|
||||
Mexp.addToken([{
|
||||
type: 0,
|
||||
show: "mexp",
|
||||
value: (a => 5 * a),
|
||||
preced: 11,
|
||||
token: "mexp"
|
||||
}]);
|
||||
Mexp.lex("mexp3").toPostfix().postfixEval();
|
||||
|
||||
Mexp.lex('mexp3').toPostfix();
|
||||
Mexp.lex('mexp3').toPostfix().formulaEval();
|
||||
25
types/math-expression-evaluator/tsconfig.json
Normal file
25
types/math-expression-evaluator/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"math-expression-evaluator-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/math-expression-evaluator/tslint.json
Normal file
3
types/math-expression-evaluator/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user