/** * Expression evaluator wired to the activated factory scope. * * Reuses the parse function and node constructors built in index.ts * and connects them to the full activated math scope, producing a top-level * `evaluate(expr, scope?)` function. * * @packageDocumentation */ import { createEvaluate } from '@danielsimonjr/mathts-expression'; /** * Parse a math expression string into an AST node. * Can be used for inspection or pre-compilation. * * Reuses the parse function built in index.ts to avoid duplicate * typed-function conversion registrations. */ export declare const parse: Parameters[0]; /** * Evaluate a math expression string against the full activated math scope. * * @param expr - Expression string (e.g., '2 + 3', 'sin(pi/2)', 'x^2') * @param scope - Optional variable bindings (e.g., { x: 3 }) * @returns The result of evaluating the expression * * @example * ```ts * evaluate('2 + 3'); // 5 * evaluate('sin(pi / 2)'); // 1 * evaluate('x^2 + 1', { x: 3 }) // 10 * ``` */ export declare const evaluate: ReturnType; /** * Compile a math expression into a reusable CompiledExpression. * * More efficient than `evaluate` when the same expression is evaluated * many times with different variable bindings. * * @param expr - Expression string to compile * @returns CompiledExpression with an evaluate(scope?) method * * @example * ```ts * const compiled = compileExpr('x^2 + y'); * compiled.evaluate({ x: 2, y: 1 }); // 5 * compiled.evaluate({ x: 3, y: 2 }); // 11 * ``` */ export declare function compileExpr(expr: string): import("@danielsimonjr/mathts-expression").CompiledExpression; /** * A stateful parser with a retained scope. Variables persist across * `evaluate` calls. * * Assignment expressions (`x = 5`) are rejected by the expression security * validator — manage retained state with `set` / `get` instead. * * @example * ```ts * const p = parser(); * p.set('x', 3); * p.evaluate('x^2'); // 9 * p.set('y', p.evaluate('x + 1')); // retain a computed value * p.get('y'); // 4 * ``` */ export declare function parser(): { /** The live scope object — assignments during `evaluate` land here. */ scope: Record; /** Evaluate an expression against the retained scope. */ evaluate(expr: string): unknown; /** Read a retained variable. */ get(name: string): unknown; /** Set a retained variable. */ set(name: string, value: unknown): void; /** Remove a retained variable. */ remove(name: string): void; /** Clear all retained variables. */ clear(): void; }; /** * `JSON.stringify` replacer that preserves non-finite numbers. `Complex` and * `Fraction` already serialize via their own `toJSON()`. */ export declare function replacer(_key: string, value: unknown): unknown; /** * `JSON.parse` reviver that reconstructs `Complex`, `Fraction`, and * non-finite numbers tagged by {@link replacer} / the types' own `toJSON()`. */ export declare function reviver(_key: string, value: unknown): unknown; //# sourceMappingURL=evaluate.d.ts.map