import { IndexedSelector } from "../types/IndexedSelector"; /** * Groups adjacent elements that share an equal key and projects each group into a result. * * @typeParam TSource - Element type produced by the source iterable. * @typeParam TKey - Key type generated by the key selector. * @typeParam TElement - Element type produced by the element selector for each group. * @typeParam TResult - Result type emitted by the group projection. * @param src - Source iterable enumerated sequentially for grouping. * @param keySelector - Selector producing a key for each source element. * @param elementSelector - Selector producing the element stored for each group member. * @param resultSelector - Projection invoked with the key and grouped elements. * @param equalityComparer - Optional key comparer; defaults to strict equality when omitted. * @returns A deferred iterable emitting one projected result for each run of equal keys. * * @example * ```ts * const result = [..._groupAdjacent( * [1, 1, 2, 3, 3], * (value) => value, * (value) => value * 2, * (key, items) => ({ key, doubled: [...items] }) * )]; * console.log(result); * // [ * // { key: 1, doubled: [2, 2] }, * // { key: 2, doubled: [4] }, * // { key: 3, doubled: [6, 6] } * // ] * ``` * * or using the curried version: * ```ts * const result = pipeInto( * ["a", "a", "b"], * groupAdjacent( * (value) => value, * (value) => value.toUpperCase(), * (key, items) => ({ key, items: [...items] }) * ) * ); * console.log([...result]); * // [ * // { key: "a", items: ["A", "A"] }, * // { key: "b", items: ["B"] } * // ] * ``` */ export declare function _groupAdjacent(src: Iterable, keySelector: IndexedSelector, elementSelector: IndexedSelector, resultSelector: (key: TKey, items: Iterable) => TResult, equalityComparer?: (a: TKey | undefined, b: TKey | undefined) => boolean): Iterable; /** * Curried version of {@link _groupAdjacent}. */ export declare const groupAdjacent: (keySelector: IndexedSelector, elementSelector: IndexedSelector, resultSelector: (key: TKey, items: Iterable) => TResult, equalityComparer?: ((a: TKey | undefined, b: TKey | undefined) => boolean) | undefined) => (src: Iterable) => Iterable;