ts-iterable-functions
    Preparing search index...

    Function _takeWhile

    • Produces elements from the source iterable while the predicate returns a truthy value.

      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 once it returns a falsy value.

      Returns Iterable<T>

      A deferred iterable yielding the leading elements that satisfy pred.

      Error Rethrows any error thrown by pred.

      const leadingSmall = [..._takeWhile([1, 2, 3, 2], (value) => value < 3)];
      console.log(leadingSmall); // [1, 2]

      or using the curried version:

      const leadingSmall = [
      ...pipeInto(
      [1, 2, 3, 2],
      takeWhile((value) => value < 3)
      ),
      ];
      console.log(leadingSmall); // [1, 2]