Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Predicate<T>

A predicate is a function taking one parameter and returning a boolean. In other words the predicate checks whether some proposition holds for the parameter.

The Predicate interface offers normal function-calling, to make sure that the predicate holds (just call predicate(x)), but also some helper methods to deal with logical operations between propositions.

You can build predicates using PredicateStatic through the 'Predicate' global constant.

Type parameters

  • T

Hierarchy

  • Predicate

Callable

  • __call(x: T): boolean
  • Does the predicate hold for the value you give? Returns true or false

    The Predicate interface offers normal function-calling, to make sure that the predicate holds (just call predicate(x)), but also some helper methods to deal with logical operations between propositions.

    You can build predicates using PredicateStatic through the 'Predicate' global constant.

    Parameters

    • x: T

    Returns boolean

Index

Methods

Methods

and

  • Combines two predicates with the 'and' logical operation. For instance:

    Predicate.of((x: number) => x > 10).and(x => x < 20)
    

    Parameters

    • fn: function
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns Predicate<T>

negate

or

  • Combines two predicates with the 'or' logical operation. For instance:

    Predicate.of((x: number) => x < 5).or(x => x > 10)
    

    Parameters

    • fn: function
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns Predicate<T>

Generated using TypeDoc