Take the first items from the iterator while the predicate function holds true, after that the iterator closes.
import { pipe } from "yta";import { takeWhile, toArray } from "yta/async";import { asAsync, range } from "yta/async";await pipe( range(10), asAsync(), takeWhile((n) => n < 5), toArray(),);// => [0, 1, 2, 3, 4] Copy
import { pipe } from "yta";import { takeWhile, toArray } from "yta/async";import { asAsync, range } from "yta/async";await pipe( range(10), asAsync(), 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: