Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ahh/src/iter/mod.ts>I.takeWhile

Idiomatic type-safety structures for TypeScript.
Go to Latest
method I.takeWhile
import { I } from "https://deno.land/x/ahh@v0.10.0/src/iter/mod.ts";

Creates an Iterator that returns items while f returns true.

Examples

import { I } from "./mod.ts";

const iter = I.takeWhile(I.iter([4, 2, 3, 4]), (i) => i % 2 === 0);

console.log(iter.next()); // 4
console.log(iter.next()); // 2
console.log(iter.next()); // undefined
console.log(iter.next()); // undefined

Parameters

iter: Iterator<T>
f: (_: T) => boolean