Calculations

The Calculations module is used to provide mathematical calculations and comparison operations. Calculations involve numbers and return numerical values. Comparison operations return Boolean values and can be used for conditional display or validation. See below.

All values are returned in the form of an Either, which is either a Left<Array<Error>> or a Right<Number | Integer>.

Comparators

The @sitebender comparators provide the ability to perform deeply-nested Boolean algebra using and and or, as well as

Operators

The @sitebender operators are essentially wrappers around the JavaScript arithmetic operators and Math module operations, e.g., Math.abs (absolute value).

Operators operate on operands, which may be addends, multipliers, dividends, divisors, minuends, subtrahends, etc.

These operands are themselves operations. They can be nested to any depth (memory permitting). At the bottom of these trees of operations, the leaf nodes must evaluate to numerical values. For this purpose, injectors are used.

Injectors can inject values as constants (hard-coded into the config), or from form inputs, session or local storage, cookies, the URL, or from the optional argument (arg) to the function returned from composeOperators:

const composeOperators = operation => (arg? => Either<Array<Error>, result>)

composeOperators is a recursive function.