> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# minBy (Functional Programming) es-toolkit

Creates a function that returns the value with the smallest computed score. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, minBy(getValue));
```

::: info

Prefer the original es-toolkit [`minBy`](https://massaman.dev/reference/array/minBy.md) in ordinary code. Use this `fp` variant when composing transformations with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

:::

## Usage

`minBy` calls `getValue` for each value in the piped array and returns the value with the smallest result. If the array is empty, it returns `undefined`.

```typescript
import { minBy, pipe } from 'es-toolkit/fp';

pipe(
  [{ score: 10 }, { score: 30 }, { score: 20 }],
  minBy(item => item.score)
); // => { score: 10 }
```

#### Parameters


getValue(item: T) => numberrequired

The function that returns the value used for comparison.

#### Returns

A function that maps a `readonly T[]` to the minimum item, or `undefined`.

```typescript
(array: readonly T[]) => T | undefined
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/fp/reference/minBy.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
