| 1 | import { ValueIteratee } from '../_internal/ValueIteratee.mjs';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Creates an object composed of keys generated from the results of running each element of collection through iteratee.
|
|---|
| 5 | * The order of grouped values is determined by the order they occur in collection.
|
|---|
| 6 | *
|
|---|
| 7 | * @template T - The type of elements in the array-like collection
|
|---|
| 8 | * @param {ArrayLike<T> | null | undefined} collection - The collection to iterate over
|
|---|
| 9 | * @param {ValueIteratee<T>} [iteratee=identity] - The iteratee to transform keys
|
|---|
| 10 | * @returns {Record<string, T[]>} Returns the composed aggregate object
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * groupBy([6.1, 4.2, 6.3], Math.floor)
|
|---|
| 14 | * // => { '4': [4.2], '6': [6.1, 6.3] }
|
|---|
| 15 | *
|
|---|
| 16 | * groupBy(['one', 'two', 'three'], 'length')
|
|---|
| 17 | * // => { '3': ['one', 'two'], '5': ['three'] }
|
|---|
| 18 | */
|
|---|
| 19 | declare function groupBy<T>(collection: ArrayLike<T> | null | undefined, iteratee?: ValueIteratee<T>): Record<string, T[]>;
|
|---|
| 20 | /**
|
|---|
| 21 | * Creates an object composed of keys generated from the results of running each element of collection through iteratee.
|
|---|
| 22 | * The order of grouped values is determined by the order they occur in collection.
|
|---|
| 23 | *
|
|---|
| 24 | * @template T - The type of the object
|
|---|
| 25 | * @param {T | null | undefined} collection - The object to iterate over
|
|---|
| 26 | * @param {ValueIteratee<T[keyof T]>} [iteratee=identity] - The iteratee to transform keys
|
|---|
| 27 | * @returns {Record<string, Array<T[keyof T]>>} Returns the composed aggregate object
|
|---|
| 28 | *
|
|---|
| 29 | * @example
|
|---|
| 30 | * groupBy({ a: 6.1, b: 4.2, c: 6.3 }, Math.floor)
|
|---|
| 31 | * // => { '4': [4.2], '6': [6.1, 6.3] }
|
|---|
| 32 | */
|
|---|
| 33 | declare function groupBy<T extends object>(collection: T | null | undefined, iteratee?: ValueIteratee<T[keyof T]>): Record<string, Array<T[keyof T]>>;
|
|---|
| 34 |
|
|---|
| 35 | export { groupBy };
|
|---|