DefinitelyTyped/expr-eval/expr-eval-tests.ts
Connor Peet 1afa463988 Add typings for expr-eval (#13628)
* Add typings for expr-eval

* Avoid use of Function type

* Use (slightly) stricter typings for expr-eval

* Update with more PR comments

* Disable linter due to bugs, allow CI to pass
2017-01-03 06:25:39 -08:00

15 lines
443 B
TypeScript

import { Parser, Expression } from 'expr-eval';
const expr = Parser.parse('2^2');
Parser.evaluate('2^2');
Parser.evaluate('2^x', { x: 2 });
Parser.evaluate('x.toUpperCase()', { x: 'hello world' });
expr.evaluate({ x: 3 });
expr.simplify();
expr.simplify({ x: 2 });
expr.variables().forEach(str => str.toUpperCase());
expr.symbols().forEach(str => str.toUpperCase());
expr.toJSFunction('y, x');
expr.toJSFunction('y, z', { y: 2 })({ z: 3 });