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/iterable.ts";

Take elements from an Iterable while a predicate is satisfied. Stops at the first element that doesn't satisfy the predicate.

@example
import * as I from "./iterable.ts";

const numbers = I.wrap(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
const whileLessThanFive = I.takeWhile((n: number) => n < 5)(numbers);

const result = Array.from(whileLessThanFive); // [1, 2, 3, 4]
function takeWhile<A>(predicate: Predicate<A>): (ta: Iterable<A>) => Iterable<A>;
§
takeWhile<A>(predicate: Predicate<A>): (ta: Iterable<A>) => Iterable<A>
[src]

§Type Parameters

§Parameters

§
predicate: Predicate<A>
[src]

§Return Type

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