source: node_modules/es-toolkit/dist/compat/array/countBy.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 947 bytes
Line 
1import { 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
5 * iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The
6 * iteratee is invoked with one argument: (value).
7 *
8 * @param collection The collection to iterate over.
9 * @param iteratee The function invoked per iteration.
10 * @return Returns the composed aggregate object.
11 *
12 * @example
13 * countBy([6.1, 4.2, 6.3], Math.floor); // => { '4': 1, '6': 2 }
14 * countBy(['one', 'two', 'three'], 'length'); // => { '3': 2, '5': 1 }
15 */
16declare function countBy<T>(collection: ArrayLike<T> | null | undefined, iteratee?: ValueIteratee<T>): Record<string, number>;
17declare function countBy<T extends object>(collection: T | null | undefined, iteratee?: ValueIteratee<T[keyof T]>): Record<string, number>;
18
19export { countBy };
Note: See TracBrowser for help on using the repository browser.