Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/evaluate"

Index

Interfaces

Functions

Functions

evaluate

  • Evaluates an arithmetic conditional. The syntax is similar to JavaScript. The allowed operations are:

    • grouping (...)
    • addition a + b
    • division a / b
    • multiplication a * b
    • subtraction a - b
    • remainder a % b
    • logical NOT not b
    • logical AND a and b
    • logical OR a or b
    • equality comparison a == b
    • inequality comparison a != b
    • greater than and equal comparison a >= b
    • greater than comparison a > b
    • less than and equal comparison a <= b
    • less than comparison a < b
    • ternary conditional a ? b : c
    • magnatude abs a
    • rounding down flooring a
    • rounding round a
    • rounding up ceil a
    • random value random(n)
    • minimum value min(n, ...)
    • maximum value max(n, ...)
    example
    const { result } = evaluate('a + b', { a: 1, b: 2 });
    console.log(result);  // -> 3
    throws

    {RangeError} there were missing variables needed to evaluate the conditional

    throws

    {TypeError} the condition was malformed

    Parameters

    Returns IEvaluateData