🧩 Finds the first item that matches a predicate.

Syntax

TypeScript
import { findIter } from '@opentf/std';

findIter<T>(iter: Iterable<T>, fn: (val: T) => boolean): T | undefined

Parameters

  • iter: The source iterable.

  • fn: The predicate function.

Returns

The first matching item, or undefined.

Examples

TypeScript
findIter([1, 2, 3], (x) => x > 1) //=> 2
Last updated on
Edit this page