/** * The `Evaluator` class is designed to evaluate mathematical expressions with support for variables and functions. */ declare class Evaluator { private variables; private functions; /** * Constructor for the Evaluator class. * @param variables - An optional object containing initial variable mappings. */ constructor(variables?: { [key: string]: number; }); /** * Evaluates a mathematical expression. * @param expression - The expression to evaluate. * @returns The numerical result of the expression. * @throws Error if the expression is invalid or contains unrecognized variables/functions. */ evaluate(expression: string): number; /** * Replaces variables and functions in the expression with their respective values or implementations. * @param expression - The expression to process. * @returns The processed expression with variables and functions replaced. * @throws Error if there are unrecognized variables after processing. */ private replaceVariablesAndFunctions; /** * Validates the syntax of the input expression. * @param expression - The expression to validate. * @throws Error if the expression contains invalid characters. */ private validateExpression; /** * Safely evaluates a processed mathematical expression. * @param expression - The processed expression to evaluate. * @returns The numerical result of the expression. * @throws Error if the expression contains invalid characters. */ private safeEval; /** * Adds or updates a variable in the evaluator. * @param name - The name of the variable. * @param value - The value of the variable. */ setVariable(name: string, value: number): void; /** * Adds or updates a custom function in the evaluator. * @param name - The name of the function. * @param func - The implementation of the function. */ setFunction(name: string, func: (...args: number[]) => number): void; } export { Evaluator };