• Category

    Determines whether all the elements of an iterable pass a given predicate.

    Time complexity: O(n)

    Space complexity: O(1)

    Type Parameters

    • T
    • S

    Parameters

    • iterable: Iterable<T>

      The iterable to take elements from

    • predicate: ((element) => element is S)

      The function to call on each element in the iterable to determine if it passes the test

        • (element): element is S
        • Parameters

          • element: T

          Returns element is S

    Returns iterable is Iterable<S>

    true if every element passed the predicate, false otherwise

    Iterable

    Example

    every([false], x => x); // false
    

    Example

    every([false, true], x => x); // false
    

    Example

    every([true], x => x); // true
    
  • Category

    Determines whether all the elements of an iterable pass a given predicate.

    Time complexity: O(n)

    Space complexity: O(1)

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>

      The iterable to take elements from

    • predicate: ((element) => unknown)

      The function to call on each element in the iterable to determine if it passes the test

        • (element): unknown
        • Parameters

          • element: T

          Returns unknown

    Returns boolean

    true if every element passed the predicate, false otherwise

    Iterable

    Example

    every([false], x => x); // false
    

    Example

    every([false, true], x => x); // false
    

    Example

    every([true], x => x); // true