es-toolkit 1.39.10-dev.1599 → 1.39.10-dev.1600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/math/sumBy.d.mts +6 -5
- package/dist/math/sumBy.d.ts +6 -5
- package/dist/math/sumBy.js +1 -1
- package/dist/math/sumBy.mjs +1 -1
- package/package.json +1 -1
package/dist/math/sumBy.d.mts
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* If the array is empty, this function returns `0`.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
|
-
* @param {T[]} items An array to calculate the sum.
|
|
9
|
-
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @param {readonly T[]} items - An array to calculate the sum.
|
|
9
|
+
* @param {(element: T, index: number) => number} getValue - A function that selects a numeric value from each element.
|
|
10
|
+
* It receives the element and its zero‑based index in the array.
|
|
10
11
|
* @returns {number} The sum of all the numbers as determined by the `getValue` function.
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
|
-
* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns:
|
|
14
|
-
* sumBy([],
|
|
14
|
+
* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8
|
|
15
|
+
* sumBy([], () => 1); // Returns: 0
|
|
15
16
|
*/
|
|
16
|
-
declare function sumBy<T>(items: readonly T[], getValue: (element: T) => number): number;
|
|
17
|
+
declare function sumBy<T>(items: readonly T[], getValue: (element: T, index: number) => number): number;
|
|
17
18
|
|
|
18
19
|
export { sumBy };
|
package/dist/math/sumBy.d.ts
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* If the array is empty, this function returns `0`.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
|
-
* @param {T[]} items An array to calculate the sum.
|
|
9
|
-
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @param {readonly T[]} items - An array to calculate the sum.
|
|
9
|
+
* @param {(element: T, index: number) => number} getValue - A function that selects a numeric value from each element.
|
|
10
|
+
* It receives the element and its zero‑based index in the array.
|
|
10
11
|
* @returns {number} The sum of all the numbers as determined by the `getValue` function.
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
|
-
* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns:
|
|
14
|
-
* sumBy([],
|
|
14
|
+
* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8
|
|
15
|
+
* sumBy([], () => 1); // Returns: 0
|
|
15
16
|
*/
|
|
16
|
-
declare function sumBy<T>(items: readonly T[], getValue: (element: T) => number): number;
|
|
17
|
+
declare function sumBy<T>(items: readonly T[], getValue: (element: T, index: number) => number): number;
|
|
17
18
|
|
|
18
19
|
export { sumBy };
|
package/dist/math/sumBy.js
CHANGED
package/dist/math/sumBy.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.39.10-dev.
|
|
3
|
+
"version": "1.39.10-dev.1600+579af7b1",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|