method Enumerable.prototype.find
Enumerable.prototype.find(findFn: (element: T) => unknown | Promise<unknown>): Promise<T | undefined>

Find the first item that matches a condition.

Examples

Find first item greater than 5

import { range } from "jsr:@j50n/proc";

const result = await range({ to: 10 })
  .find(n => n > 5);
// 6

Parameters

findFn: (element: T) => unknown | Promise<unknown>

The test function.

Return Type

Promise<T | undefined>

The first matching item, or undefined if none found.

Usage

import { Enumerable } from ".";