Constructor
new BooleanExpression(items, type)
Parameters:
Name |
Type |
Description |
items |
Array.<any>
|
The items in the boolean expression. Each item can
either be an object of an arbitrary type or a boolean expression. |
type |
string
|
The type of the boolean expression ('and'/'or'); |
- Source:
Methods
evaluate(options) → {boolean}
Parameters:
Name |
Type |
Description |
options |
object
|
The options for evaluation.
Properties
Name |
Type |
Description |
isItemTrue |
function
|
A function that takes an argument that
is an item in the boolean expression. The function returns whether the
given item is true or false. |
|
- Source:
Returns:
Whether the overall expression is true or false.
-
Type
-
boolean
isAnd() → {boolean}
- Source:
Returns:
Whether the expression is an 'and' expression.
-
Type
-
boolean
isEqualTo(options) → {boolean}
Parameters:
Name |
Type |
Description |
options |
object
|
Options for evaluating if the expressions are
equal.
Properties
Name |
Type |
Description |
otherExpression |
BooleanExpression
|
The boolean expression
to compare the expression to. |
areItemsEqual |
function
|
A function that takes two arguments
that are items in the boolean expression. This function should return
whether the two items are equal. |
|
- Source:
Returns:
Whether the boolean expression is equal to the given
other boolean expression. The items in the two expressions can be in any
order, but they must otherwise be equivalent.
-
Type
-
boolean
isOr() → {boolean}
- Source:
Returns:
Whether the expression is an 'or' expression.
-
Type
-
boolean
reduce(options) → {any}
Parameters:
Name |
Type |
Description |
options |
object
|
The options for reduction.
Properties
Name |
Type |
Description |
andInitialValue |
any
|
The initial value for an expression
with the 'and' type. |
andReducer |
function
|
A function that takes an object with
three keys: `accumulator` (the accumulated value for the current
expression), `item` (the current item), and `isReduced` (whether the
current item is a nested boolean expression that has already been
reduced). This function is only used for expressions that have the 'and'
type. |
orInitialValue |
any
|
The initial value for an expression
with the 'or' type. |
orReducer |
function
|
A function that takes an object with
three keys: `accumulator` (the accumulated value for the current
expression), `item` (the current item), and `isReduced` (whether the
current item is a nested boolean expression that has already been
reduced). This function is only used for expressions that have the 'or'
type. |
|
- Source:
Returns:
The reduced value of the expression.
-
Type
-
any
Parameters:
Name |
Type |
Description |
options |
object
|
The options for simplification.
Properties
Name |
Type |
Description |
implies |
function
|
A function that takes two arguments that
are both items in the boolean expression. The function returns whether
the first item being true implies that the second item is true. For
example, "X > 5" would imply "X > 3". |
|
- Source:
Returns:
The simplified boolean expression.
-
Type
-
BooleanExpression
Constructs a new boolean expression with the 'and' type.
Parameters:
Name |
Type |
Attributes |
Description |
items |
any
|
<repeatable>
|
The items in the boolean expression. Each item can
either be an object of an arbitrary type or a boolean expression. |
- Source:
Returns:
The new boolean expression.
-
Type
-
BooleanExpression
Constructs a new boolean expression with the 'or' type.
Parameters:
Name |
Type |
Attributes |
Description |
items |
any
|
<repeatable>
|
The items in the boolean expression. Each item can
either be an object of an arbitrary type or a boolean expression. |
- Source:
Returns:
The new boolean expression.
-
Type
-
BooleanExpression