Skip to content

Latest commit

 

History

History
209 lines (147 loc) · 9.01 KB

File metadata and controls

209 lines (147 loc) · 9.01 KB

Classes

AsyncBooleanExpressionEvaluator

A parser for evaluating boolean expressions, passing each operand to an asynchronous iterator

Typedefs

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 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.

OrExpression : object

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.

NotExpression : object

An object with the key not set to an Operand. The expression will only evaluate to true if the operand evaluates to false.

AsyncBooleanExpressionEvaluator

A parser for evaluating boolean expressions, passing each operand to an asynchronous iterator

Kind: global class

new AsyncBooleanExpressionEvaluator(iterator)

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.

asyncBooleanExpressionEvaluator.iterator ⇒ function

Gets the iterator

Kind: instance property of AsyncBooleanExpressionEvaluator

asyncBooleanExpressionEvaluator.iterator

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

asyncBooleanExpressionEvaluator.parallelLimit

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

asyncBooleanExpressionEvaluator.parallelLimit ⇒ Number

Gets the parallelLimit

Kind: instance property of AsyncBooleanExpressionEvaluator

asyncBooleanExpressionEvaluator.execute(expression, [callback]) ⇒ Promise

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

asyncBooleanExpressionEvaluator.clearCache()

Clears the iterator result cache

Kind: instance method of AsyncBooleanExpressionEvaluator

asyncBooleanExpressionEvaluator.validateExpression(expression) ⇒ boolean

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

asyncBooleanExpressionEvaluator.evaluateExpression(expression, [callback]) ⇒ Promise

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

asyncBooleanExpressionEvaluator.getIteratorResult(operand) ⇒ Promise

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

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.

Kind: global typedef

AndExpression : object

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>

OrExpression : object

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>

NotExpression : object

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