For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/find.md.

find (Functional Programming) es-toolkit

Creates a function that returns the first value that passes a test. Use it with pipe.

const result = pipe(array, find(predicate));
Info

This helper is specific to es-toolkit/fp. Use it when you want this operation as part of a pipe pipeline.

Usage

find returns the first value in the piped array for which predicate returns true. If no value matches, it returns undefined.

import { find, pipe } from 'es-toolkit/fp';

pipe(
  [1, 2, 3, 4],
  find(value => value > 2)
); // => 3

Parameters

predicate(value: T, index: number) => booleanrequired

The function that tests each value.

Returns

A function that maps a readonly T[] to the first matching value, or undefined.

(array: readonly T[]) => T | undefined
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.