• 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: T) => 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

    every([false], x => x); // false
    
    every([false, true], x => x); // false
    
    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: T) => 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

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