ESCalc - v0.0.1-beta.2
    Preparing search index...

    Function evaluate

    • Parse and evaluate an NCalc expression in a single step.

      When expression is a string it is first parsed into an AST then evaluated. Passing a pre-parsed LogicalExpression skips the parse step.

      Parameters

      Returns unknown

      The result produced by evaluating the expression.

      ParserError If expression is a string that cannot be parsed.

      ESCalcError If a runtime error occurs during evaluation (e.g. referencing an unknown parameter, or a type mismatch in an operator).

      import { evaluate } from 'escalc';

      evaluate('1 + 2'); // => 3

      evaluate('[x] * [y]', { params: new Map([['x', 3], ['y', 4]]) }); // => 12

      evaluate('Max(Abs(-5), 2)'); // => 5