ts-iterable-functions
    Preparing search index...

    Function takeWhileConst

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

      Curried version of _takeWhile.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • pred: IndexedPredicate<T>

        Predicate receiving each element and its index; iteration stops once it returns a falsy value.

      Returns (src: Iterable) => Iterable

      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]