docs/fp/reference/minBy.md
Creates a function that returns the value with the smallest computed score. Use it with pipe.
const result = pipe(array, minBy(getValue));
::: info
Prefer the original es-toolkit minBy in ordinary code. Use this fp variant when composing transformations with pipe.
:::
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.
import { minBy, pipe } from 'es-toolkit/fp';
pipe(
[{ score: 10 }, { score: 30 }, { score: 20 }],
minBy(item => item.score)
); // => { score: 10 }
getValue ((item: T) => number): The function that returns the value used for comparison.((array: readonly T[]) => T | undefined): A function that maps a readonly T[] to the minimum item, or undefined.