Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/ahh/mod.ts>I.find

Idiomatic type-safety functions.
Go to Latest
method I.find
import { I } from "https://deno.land/x/ahh@v0.10.3/mod.ts";

Consumes an Iterator until f returns true and returns the item.

Examples

Example 1

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

const iter = I.iter([1, 2, 3]);

console.log(I.find(iter, (i) => i > 1)); // 2
console.log(iter.next()); // 3
console.log(iter.next()); // undefined

Parameters

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