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

    Function atLeast

    • Determines whether source contains at least count elements that satisfy the optional predicate.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The iterable whose elements are evaluated.

      • count: number

        Minimum number of matching elements required. Must be greater than or equal to 0.

      • Optionalpredicate: Predicate<TElement>

        Optional predicate that determines which elements are counted. When omitted, every element is considered a match.

      Returns boolean

      true when at least count matching elements are present; otherwise, false.

      Thrown when count is negative.

      Re-throws any error encountered while iterating source or executing the predicate.

      Enumeration stops as soon as the required number of matches is found, avoiding unnecessary work on long iterables.

      const numbers = [1, 2, 3, 4, 5];
      const hasAtLeastTwoEvens = atLeast(numbers, 2, n => n % 2 === 0);
      console.log(hasAtLeastTwoEvens); // true