@mikuroxina/mini-fn
    Preparing search index...

    Function takeWhile

    • Takes while the element satisfies pred. If the element matches pred, the list will fuse at the element.

      Type Parameters

      • T

      Parameters

      • pred: (t: T) => boolean

        The condition to decide to stop the list.

      Returns (list: List.List<T>) => List.List<T>

      The filtered list.

      Examples

      const nums = range(1, 100);
      const takeWhileSquared = takeWhile((x: number) => x * x <= 20)(nums);
      expect(toArray(takeWhileSquared)).toStrictEqual([1, 2, 3, 4]);