Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Pred

Class representing Predicates, the building block of specs. It is important that your predicates are as simple as possible to aid in debugging, because simple predicates will meaningfully inform exactly what the issue is.

Hierarchy

Constructors

Properties

Methods

Constructors

constructor

  • new Pred(name: string, options: any): Pred
  • Parameters

    • name: string
    • options: any

    Returns Pred

Properties

name

name: string

options

options: any

Methods

assert

  • assert(value: any): any
  • Asserts this spec on a given value. Returns the value if value passes spec, returns perusal-immutable.invalid otherwise.

    throws

    Throws an error if predicate function does not return boolean when fed with input value.

    throws

    Throws an error if predicate function does not return boolean when fed with input value.

    Parameters

    • value: any

      The value to be asserted.

    Returns any

    Returns the value if value passes spec, returns perusal-immutable.invalid otherwise.

explain

  • explain(value: any, path: string[]): boolean
  • Explains why a value passes/fails this spec. Prints out the path to this pred if value fails at this pred.

    Parameters

    • value: any

      The value to be checked.

    • path: string[]

      The path travelled to this spec.

    Returns boolean

    Returns true if the value satisfies this spec, false otherwise.

Generated using TypeDoc