import { IndexedSelector } from "../types/IndexedSelector"; import { SetFactory } from "../types/SetFactory"; /** * Emits source elements while removing duplicates identified by the selector key. * * @typeParam T - Element type produced by the source iterable. * @typeParam TKey - Key type returned by the selector. * @param src - Source iterable enumerated for distinct values. * @param selector - Selector producing a comparison key for each element. * @param setFactory - Optional factory supplying the set used to track seen keys. * @returns A deferred iterable yielding the first element for each unique key. * @throws Error Rethrows any error thrown by `selector` or `setFactory`. * * @example * ```ts * const users = [ * { id: 1, name: "Ada" }, * { id: 1, name: "Ada" }, * { id: 2, name: "Grace" }, * ]; * const unique = [..._distinctBy(users, (user) => user.id)]; * console.log(unique); // [{ id: 1, name: "Ada" }, { id: 2, name: "Grace" }] * ``` * * or using the curried version: * ```ts * const unique = [ * ...pipeInto( * [ * { id: 1, name: "Ada" }, * { id: 1, name: "Ada" }, * { id: 2, name: "Grace" }, * ], * distinctBy((user) => user.id) * ), * ]; * console.log(unique); // [{ id: 1, name: "Ada" }, { id: 2, name: "Grace" }] * ``` */ export declare function _distinctBy(src: Iterable, selector: IndexedSelector, setFactory?: SetFactory): Iterable; /** * Curried version of {@link _distinctBy}. */ export declare const distinctBy: (selector: IndexedSelector, setFactory?: SetFactory | undefined) => (src: Iterable) => Iterable;