Constructor
new DynamicEvaluator(compiledopt)
Parameters:
- Source:
Classes
Members
compiledExpressions :Object:.<string:, function(object:): any:>|null
Expressions the compiler already turned into closures.
When an entry exists it is used, and neither the parser nor the interpreter is reached. That is the whole point: a build in which every expression compiled never executes the interpreter, which is what allows it to be dropped from a production bundle.
Type:
- Source:
compiledStatements :Object:.<string:, function(object:): any:>|null
Statement bodies the compiler already turned into closures.
Type:
- Source:
indexedExpressions :Array:.<function(object:): any:>|null
Compiled closures addressed by index, for the render program.
Separate from the source-keyed table rather than overloading it. A program op carries an index and a legacy binding carries source text; one table serving both would have to guess which it was handed, and a numeric string key is a real expression source.
Type:
- Source:
indexedStatements :Array:.<function(object:): any:>|null
Compiled statement closures addressed by index, for event ops.
Type:
- Source:
Methods
createMethodMap(methodsopt, getScope, getThisArg, contextopt) → {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. |
||||||||||||||||||||||||||
context |
object |
<optional> |
null | Trace context describing who owns these methods. Properties
|
- Source:
Returns:
A map of functions.
- Type
- object
evaluateExpression(expression, scopeopt, thisArgopt) → {any}
Evaluates a JavaScript expression within a scope.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
expression |
string | The expression to evaluate. |
|
scope |
object |
<optional> |
The scope variables. |
thisArg |
object |
<optional> |
The 'this' context for evaluation. |
- Source:
Returns:
The result of evaluation.
- Type
- any
evaluateIndexed(index, scopeopt, thisArgopt) → {any}
Evaluates a compiled expression by index.
There is no interpreter fallback here, and that is deliberate. An index names a closure and nothing else -- the source it came from is not in the bundle -- so a missing entry is a program and a table that disagree, which is a build fault rather than a template the runtime could still render. The compiler refuses to emit a program whose expressions did not all compile, so this cannot be reached by an application that built.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
index |
number | The expression index. |
|
scope |
object |
<optional> |
The scope variables. |
thisArg |
object |
<optional> |
The |
- Source:
Returns:
The value.
- Type
- any
executeIndexed(index, scopeopt, thisArgopt) → {any}
Runs a compiled statement body by index.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
index |
number | The statement index. |
|
scope |
object |
<optional> |
The scope variables. |
thisArg |
object |
<optional> |
The |
- Source:
Returns:
Whatever the body returned.
- Type
- any
executeStatement(source, scopeopt, thisArgopt) → {any}
Executes a JavaScript statement within a scope.
This used to accept a pre-compiled function as well, for handlers
EventExecutor had already built with new Function, and ran those
against the source-text sandbox rather than the AST evaluator. Nothing
produces such a function any more, and accepting one would be a door back
into the sandbox the evaluator exists to replace.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
source |
string | The statement(s) to execute. |
|
scope |
object |
<optional> |
The scope variables. |
thisArg |
object |
<optional> |
The 'this' context for execution. |
- Source:
Returns:
The result of execution.
- Type
- any
sanitizeHTML(value, optionsopt) → {string}
Sanitizes an HTML string using the Sanitizer utility with optional custom policy configuration.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
value |
any | The HTML string or value to sanitize. |
|
options |
object |
<optional> |
Optional custom policy configuration for Sanitizer. |
- Source:
Returns:
The sanitized HTML string.
- Type
- string