effect-io-ai

Package: effect
Module: Array

Array.findFirstIndex

Returns the index of the first element matching the predicate, wrapped in an Option.

When to use

Use to find the index of the first matching element from the start of an iterable.

Example (Finding an index)

import { Array } from "effect"

console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // Option.some(2)

See

Signature

declare const findFirstIndex: { <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option.Option<number>; <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<number>; }

Source

Since v2.0.0