ConstElement type produced by the source iterable.
Key type produced by the selector and consumed by the comparer.
Selector receiving each element and its index, producing the key used for comparison.
Comparer determining ordering between keys; defaults to defaultComparer.
An iterable containing every element sharing the minimal key, or an empty iterable when the source is empty.
const tasks = [
{ id: 1, duration: 12 },
{ id: 2, duration: 5 },
{ id: 3, duration: 5 },
];
const quickest = [..._minBy(tasks, (task) => task.duration)];
console.log(quickest);
// [ { id: 2, duration: 5 }, { id: 3, duration: 5 } ]
or using the curried version:
const quickest = [
...pipeInto(
[
{ id: 1, duration: 12 },
{ id: 2, duration: 5 },
{ id: 3, duration: 5 },
],
minBy((task) => task.duration)
),
];
console.log(quickest);
// [ { id: 2, duration: 5 }, { id: 3, duration: 5 } ]
Selects the elements whose key value is minimal according to the comparer.
Curried version of _minBy.