The condition to decide to stop the list.
The filtered list.
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
Takes while the element satisfies
pred
. If the element matchespred
, the list will fuse at the element.