@mirei/ts-collections
    Preparing search index...

    Function all

    • Determines whether every element in the sequence satisfies the supplied predicate.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • predicate: Predicate<TElement>

        Function that evaluates each element and returns true when it satisfies the condition.

      Returns boolean

      true when all elements satisfy the predicate; otherwise, false.

      Enumeration stops as soon as the predicate returns false.

      const numbers = [1, 2, 3, 4, 5];
      const allPositive = all(numbers, x => x > 0);
      console.log(allPositive); // true

      const mixedNumbers = [-1, 2, 3, -4, 5];
      const allPositive2 = all(mixedNumbers, x => x > 0);
      console.log(allPositive2); // false