Class: DynamicEvaluator

DynamicEvaluator()

Provides dynamic expression and statement evaluation within a given scope.

Constructor

new DynamicEvaluator()

Source:

Methods

createMethodMap(methodsopt, getScope, getThisArg) → {Object}

Creates a map of executable methods from string definitions.

Parameters:
Name Type Attributes Default Description
methods Object <optional>
{}

An object containing method name and source code pairs.

getScope function

Function to retrieve the scope for a method.

getThisArg function

Function to retrieve the 'this' context for methods.

Source:
Returns:

A map of functions.

Type
Object

evaluateExpression(expression, scopeopt, thisArgopt) → {any}

Evaluates a JavaScript expression within a scope.

Parameters:
Name Type Attributes Default Description
expression string

The expression to evaluate.

scope Object <optional>
{}

The scope variables.

thisArg Object <optional>
scope

The 'this' context for evaluation.

Source:
Returns:

The result of evaluation.

Type
any

executeStatement(source, scopeopt, thisArgopt) → {any}

Executes a JavaScript statement within a scope.

Parameters:
Name Type Attributes Default Description
source string

The statement(s) to execute.

scope Object <optional>
{}

The scope variables.

thisArg Object <optional>
scope

The 'this' context for execution.

Source:
Returns:

The result of execution.

Type
any