Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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
}
function takeWhile<A>(predicate: Predicate<A>): (ta: AsyncIterable<A>) => AsyncIterable<A>;
§
takeWhile<A>(predicate: Predicate<A>): (ta: AsyncIterable<A>) => AsyncIterable<A>
[src]

§Type Parameters

§Parameters

§
predicate: Predicate<A>
[src]

§Return Type

§
(ta: AsyncIterable<A>) => AsyncIterable<A>
[src]