ts-iterable-functions
    Preparing search index...

    Function _takeToInclusive

    • Collects elements from the source iterable until the predicate first returns a truthy value, including that element.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable to enumerate.

      • pred: IndexedPredicate<T>

        Predicate receiving each element and its index; iteration stops after it returns a truthy value.

      Returns Iterable<T>

      A deferred iterable yielding items up to and including the element that satisfies pred.

      Error Rethrows any error thrown by pred.

      const inclusive = [..._takeToInclusive([1, 2, 3, 4, 5], (value) => value >= 3)];
      console.log(inclusive); // [1, 2, 3]

      or using the curried version:

      const inclusive = [
      ...pipeInto(
      [1, 2, 3, 4, 5],
      takeToInclusive((value) => value >= 3)
      ),
      ];
      console.log(inclusive); // [1, 2, 3]