source: node_modules/es-toolkit/dist/math/meanBy.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: 716 bytes
Line 
1/**
2 * Calculates the average of an array of numbers when applying
3 * the `getValue` function to each element.
4 *
5 * If the array is empty, this function returns `NaN`.
6 *
7 * @template T - The type of elements in the array.
8 * @param {T[]} items An array to calculate the average.
9 * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
10 * @returns {number} The average of all the numbers as determined by the `getValue` function.
11 *
12 * @example
13 * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2
14 * meanBy([], x => x.a); // Returns: NaN
15 */
16declare function meanBy<T>(items: readonly T[], getValue: (element: T) => number): number;
17
18export { meanBy };
Note: See TracBrowser for help on using the repository browser.