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

    Function parseSafe

    • The same as parse but returns a discriminated union instead of throwing.

      Parameters

      • expression: string

        The NCalc expression string to parse.

      • OptionalparserOptions: { stopOnFirstError?: boolean }

        Optional parse settings.

      Returns
          | { expression: LogicalExpression; type: "success" }
          | { error: ParserError; type: "error" }

      { type: 'success', expression } on success, or { type: 'error', error } containing a ParserError on failure.

      const result = parseSafe('1 + ');
      if (result.type === 'error') {
      console.error(result.error.errors[0].detailedMessage);
      }