🧩 Finds the index of the first item that matches a predicate.
Syntax
TypeScript
import { findIndexIter } from '@opentf/std'; findIndexIter<T>(iter: Iterable<T>, fn: (val: T) => boolean): number
Parameters
iter: The source iterable.fn: The predicate function.
Returns
The index of the first matching item, or -1.
Examples
TypeScript
findIndexIter([1, 2, 3], (x) => x === 2) //=> 1