ExpressionCalculator

Implements an expression calculator.

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

defaultVariables

List with default variables.

public defaultVariables(): IVariableCollection

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[]

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[]

variantOperations

Gets the manager for operations on variant values.

public variantOperations(): IVariantOperations

Sets the manager for operations on variant values.

public variantOperations(value: IVariantOperations)

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

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>

evaluateWithVariablesAndFunctions

Evaluates this expression using specified variables and functions.

public evaluateWithVariablesAndFunctions(variables: IVariantOperations, functions: IFunctionCollection): Promise<Variant>