Take the first items from the iterator while the predicate function holds true, after that the iterator closes.
import { pipe } from "yta";import { range, takeWhile, toArray } from "yta/sync";pipe( range(10), takeWhile((n) => n < 5), toArray(),);// => [0, 1, 2, 3, 4] Copy
import { pipe } from "yta";import { range, takeWhile, toArray } from "yta/sync";pipe( range(10), takeWhile((n) => n < 5), toArray(),);// => [0, 1, 2, 3, 4]
See also:
The item type
The predicate function
Take the first items from the iterator while the predicate function holds true, after that the iterator closes.
See also: