Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/ahh/src/iterator.ts>Iterator#find

Opinionated idiomatic features for TypeScript.
Latest
method Iterator.prototype.find
import { Iterator } from "https://deno.land/x/ahh@v0.14.0/src/iterator.ts";

Consumes this until fn returns true, and returns the item.

Examples

Example 1

import { assert } from "../test_deps.ts";
import I from "./iterator.ts";

const odd = (i: number): boolean => i % 2 !== 0;
const iter = I.fromIter([1, 2, 3]);

assert(iter.find(odd) === 1);
assert(iter.find(odd) === 3);

Parameters

fn: (item: T) => boolean