- AsyncBooleanExpressionEvaluator
A parser for evaluating boolean expressions, passing each operand to an asynchronous iterator
- Operand :
*|AndExpression|OrExpression|NotExpression An operand is a value of any type, which is passed into the iterator; or an AndExpression, OrExpression, or NotExpression, which can be used to assemble more complex expressions out of a series of nested operands. AndExpressions, OrExpressions, and NotExpressions may be nested recursively.
- AndExpression :
object An object with the key
andset to an array of Operands. The expression will only evaluate to true if all of the operands evaluate to true. If any operand does evaluate to false, further operands will not be evaluated.- OrExpression :
object An object with the key
orset to an array of Operands. The expression will only evaluate to true if any of the operands evaluates to true. If any operand evaluates to true, further operands will not be evaluated.- NotExpression :
object An object with the key
notset to an Operand. The expression will only evaluate to true if the operand evaluates to false.
A parser for evaluating boolean expressions, passing each operand to an asynchronous iterator
Kind: global class
- AsyncBooleanExpressionEvaluator
- new AsyncBooleanExpressionEvaluator(iterator)
- .iterator ⇒
function - .iterator
- .parallelLimit
- .parallelLimit ⇒
Number - .execute(expression, [callback]) ⇒
Promise - .clearCache()
- .validateExpression(expression) ⇒
boolean - .evaluateExpression(expression, [callback]) ⇒
Promise - .getIteratorResult(operand) ⇒
Promise
Creates a new evaluator for boolean expressions, given a function to perform an async test against an operand
| Param | Type | Description |
|---|---|---|
| iterator | function |
See #set iterator for details. |
Gets the iterator
Kind: instance property of AsyncBooleanExpressionEvaluator
Sets the iterator
Kind: instance property of AsyncBooleanExpressionEvaluator
| Param | Type | Description |
|---|---|---|
| iterator | function |
A function that accepts an operand and returns a Promise that resolves with whether the given operand is considered true or false |
Sets the parallelLimit
Kind: instance property of AsyncBooleanExpressionEvaluator
Throws:
TypeError
| Param | Type | Description |
|---|---|---|
| parallelLimit | Number |
The maximum number of asynchronous iterators that can be run in parallel |
Gets the parallelLimit
Kind: instance property of AsyncBooleanExpressionEvaluator
Validates then executes the given boolean expression
Kind: instance method of AsyncBooleanExpressionEvaluator
Returns: Promise - The result of evaluating the expression
| Param | Type | Description |
|---|---|---|
| expression | Operand |
The expression to execute |
| [callback] | function |
An optional callback to invoke when the promise is resolved or rejected |
Clears the iterator result cache
Kind: instance method of AsyncBooleanExpressionEvaluator
Validates the given boolean expression conforms to the correct format
Kind: instance method of AsyncBooleanExpressionEvaluator
Returns: boolean - True if the expression is valid
Throws:
TypeError
| Param | Type | Description |
|---|---|---|
| expression | Operand |
The boolean expression to validate |
Tests each operand in the expression against the asynchronous iterator. Will short-circuit whenever possible, and caches the results of operands against the iterator
Kind: instance method of AsyncBooleanExpressionEvaluator
Returns: Promise - A promise that resolves with the result of the expression or rejects if the iterator rejects
Throws:
TypeError
| Param | Type | Description |
|---|---|---|
| expression | Operand |
The expression to evaluate |
| [callback] | function |
An optional callback to invoke when the promise is resolved or rejected |
Invokes the iterator for the given operand, or returns its cached result
Kind: instance method of AsyncBooleanExpressionEvaluator
Returns: Promise - The promise returned from the iterator
| Param | Type | Description |
|---|---|---|
| operand | Operand |
The operand to pass into the iterator |
Operand : * | AndExpression | OrExpression | NotExpression
An operand is a value of any type, which is passed into the iterator; or an AndExpression, OrExpression, or NotExpression, which can be used to assemble more complex expressions out of a series of nested operands. AndExpressions, OrExpressions, and NotExpressions may be nested recursively.
An object with the key and set to an array of Operands. The expression will only evaluate to true if all of the
operands evaluate to true. If any operand does evaluate to false, further operands will not be evaluated.
Kind: global typedef
Properties
| Name | Type |
|---|---|
| and | Array.<Operand> |
An object with the key or set to an array of Operands. The expression will only evaluate to true if any of the
operands evaluates to true. If any operand evaluates to true, further operands will not be evaluated.
Kind: global typedef
Properties
| Name | Type |
|---|---|
| or | Array.<Operand> |
An object with the key not set to an Operand. The expression will only evaluate to true if the operand evaluates to
false.
Kind: global typedef
Properties
| Name | Type |
|---|---|
| not | Operand |