Description
The ExpressionCalculator class allows you to create an expression calculator.
Constructors
Constructs this class and a assigns expression string.
public
constructor(expression?: string)
- expression: string - expression string.
Properties
autoVariables
Gets the flag to turn on auto-creation of variables for a specified expression.
public
autoVariables(): boolean
- returns: boolean - returns the flag to turn on auto-creation.
Sets the flag to turn on auto-creation of variables for specified expression.
public
autoVariables(value: boolean)
- value: boolean - flag to turn on auto-creation.
defaultFunctions
List with default functions.
public
defaultFunctions(): IFunctionCollection
- returns: IFunctionCollection - list with default functions.
defaultVariables
List with default variables.
public
defaultVariables(): IVariableCollection
- returns: IVariableCollection - list with default variables.
expression
Expression string.
public
expression(): string
- returns: string - expression string.
public
expression(value: string)
- value: string - expression string.
initialTokens
List of original expression tokens.
public
initialTokens(): ExpressionToken[]
- returns: ExpressionToken[] - list of original expression tokens.
originalTokens
List of expression tokens.
public
originalTokens(): Token[]
- returns: Token[] - list of expression tokens.
public
originalTokens(value: Token[])
- value: Token[] - list of expression tokens.
resultTokens
List of processed expression tokens.
public
resultTokens(): ExpressionToken[]
- returns: ExpressionToken[] - list of processed expression tokens.
variantOperations
Gets the manager for operations on variant values.
public
variantOperations(): IVariantOperations
- returns: IVariantOperations - manager for operations.
Sets the manager for operations on variant values.
public
variantOperations(value: IVariantOperations)
- value: IVariantOperations - manager for operations.
Instance methods
clear
Cleans up this calculator from all data.
public
clear(): void
createVariables
Cleans up this calculator from all data.
public
createVariables(variables: IVariantOperations): void
- variables: IVariantOperations - list of variables to be populated.
evaluate
Evaluates this expression using default variables and functions.
public
evaluate(): Promise<Variant>
- returns: Promise<Variant> - evaluation result.
evaluateWithVariables
Evaluates this expression using specified variables.
public
evaluateWithVariables(variables: IVariantOperations): Promise<Variant>
- variables: IVariantOperations - list of variables.
- returns: Promise<Variant> - evaluation result.
evaluateWithVariablesAndFunctions
Evaluates this expression using specified variables and functions.
public
evaluateWithVariablesAndFunctions(variables: IVariantOperations, functions: IFunctionCollection): Promise<Variant>
- variables: IVariantOperations - list of variables.
- functions: IFunctionCollection - list of functions
- returns: Promise<Variant> - evaluation result.