source: node_modules/es-toolkit/dist/compat/math/sumBy.d.ts

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

Added visualizations

  • Property mode set to 100644
File size: 781 bytes
Line 
1/**
2 * Computes the sum of the values that are returned by the `iteratee` function.
3 *
4 * It does not coerce values to `number`.
5 *
6 * @template T - The type of the array elements.
7 * @param {ArrayLike<T> | null | undefined} array - The array to iterate over.
8 * @param {((value: T) => number) | string} iteratee - The function invoked per iteration.
9 * @returns {number} Returns the sum.
10 *
11 * @example
12 * sumBy([1, undefined, 2], value => value); // => 3
13 * sumBy(null); // => 0
14 * sumBy(undefined); // => 0
15 * sumBy([1, 2, 3]); // => 6
16 * sumBy([1n, 2n, 3n]); // => 6n
17 * sumBy([{ a: "1" }, { a: "2" }], object => object.a); // => "12"
18 */
19declare function sumBy<T>(array: ArrayLike<T> | null | undefined, iteratee?: ((value: T) => number) | string): number;
20
21export { sumBy };
Note: See TracBrowser for help on using the repository browser.