forked from silentmatt/expr-eval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.d.ts
67 lines (63 loc) · 1.63 KB
/
parser.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export type Value = number
| string
| ((...args: Value[]) => Value)
| { [propertyName: string]: Value };
export interface Values {
[propertyName: string]: Value;
}
export interface ParserOptions {
allowMemberAccess?: boolean;
operators?: {
add?: boolean,
comparison?: boolean,
concatenate?: boolean,
conditional?: boolean,
divide?: boolean,
factorial?: boolean,
logical?: boolean,
multiply?: boolean,
power?: boolean,
remainder?: boolean,
subtract?: boolean,
sin?: boolean,
cos?: boolean,
tan?: boolean,
asin?: boolean,
acos?: boolean,
atan?: boolean,
sinh?: boolean,
cosh?: boolean,
tanh?: boolean,
asinh?: boolean,
acosh?: boolean,
atanh?: boolean,
sqrt?: boolean,
log?: boolean,
ln?: boolean,
lg?: boolean,
log10?: boolean,
abs?: boolean,
ceil?: boolean,
floor?: boolean,
round?: boolean,
trunc?: boolean,
exp?: boolean,
length?: boolean,
in?: boolean
};
}
export class Parser {
constructor(options?: ParserOptions);
parse(expression: string): Expression;
evaluate(expression: string, values?: Value): number;
static parse(expression: string): Expression;
static evaluate(expression: string, values?: Value): number;
}
export interface Expression {
simplify(values?: Value): Expression;
evaluate(values?: Value): number;
substitute(values: Value): Expression;
symbols(options?: { withMembers?: boolean }): string[];
variables(options?: { withMembers?: boolean }): string[];
toJSFunction(params: string, values?: Value): (...args: any[]) => number;
}