takeWhile
import { takeWhile } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async_iterable.ts";Take values from an AsyncIterable while a predicate is true.
@example
import { takeWhile } from "./async_iterable.ts";
import { fromIterable } from "./async_iterable.ts";
import { pipe } from "./fn.ts";
const numbers = fromIterable([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const result = pipe(
numbers,
takeWhile(n => n <= 5)
);
for await (const value of result) {
console.log(value); // 1, 2, 3, 4, 5
}