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

    Type Parameters

    • T

    Parameters

    • pred: ((t) => boolean)

      The condition to decide to stop the list.

        • (t): boolean
        • Parameters

          • t: T

          Returns boolean

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

    The filtered list.

    Examples

    import { range, takeWhile, toArray } from "./list.ts";
    import { assertEquals } from "../deps.ts";

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

Generated using TypeDoc