@jonahsnider/util

    Function every

    • 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

      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
      
    • 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

      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
      
    MMNEPVFCICPMFPCPTTAAATR