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

    Function execute

    • Execute a pre-parsed (or string) NCalc expression.

      Unlike evaluate, this function emphasises that execution is separate from parsing. When expression is a string it is parsed internally, but prefer evaluate for single-shot parse-and-evaluate. Use execute when you need to hold a StandardEvaluator or pass custom options without re-parsing.

      Parameters

      Returns unknown

      The result produced by executing the expression.

      ParserError If expression is a string that cannot be parsed.

      ESCalcError If a runtime error occurs during execution.

      import { parse, execute } from 'escalc';

      const ast = parse('[price] * (1 + [tax])');

      // Reuse the same AST with different parameters
      execute(ast, { params: new Map([['price', 100], ['tax', 0.2]]) }); // => 120
      execute(ast, { params: new Map([['price', 200], ['tax', 0.1]]) }); // => 220