import { Comparer } from "ts-comparer-builder"; import { IndexedSelector } from "../types/IndexedSelector"; /** * Selects the elements whose key value is minimal according to the comparer. * * @typeParam T - Element type produced by the source iterable. * @typeParam TKey - Key type produced by the selector and consumed by the comparer. * @param src - Source iterable to evaluate. * @param selector - Selector receiving each element and its index, producing the key used for comparison. * @param comparer - Comparer determining ordering between keys; defaults to {@link defaultComparer}. * @returns An iterable containing every element sharing the minimal key, or an empty iterable when the source is empty. * @throws Error Rethrows any error thrown by `selector` or `comparer`. * * @example * ```ts * 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: * ```ts * 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 } ] * ``` */ export declare function _minBy(src: Iterable, selector: IndexedSelector, comparer?: Comparer): Iterable; /** * Curried version of {@link _minBy}. */ export declare const minBy: (selector: IndexedSelector, comparer?: Comparer | undefined) => (src: Iterable) => Iterable;