es-toolkit 1.10.0-dev.205 → 1.10.0-dev.206
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/array/index.mjs +33 -33
- package/dist/chunk-5L4VWRFX.mjs +14 -0
- package/dist/chunk-5L4VWRFX.mjs.map +1 -0
- package/dist/chunk-FUS75PJ7.mjs +1 -0
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +10 -2
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +70 -66
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -66
- package/dist/math/index.d.mts +1 -0
- package/dist/math/index.d.ts +1 -0
- package/dist/math/index.js +10 -2
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +6 -2
- package/dist/math/sumBy.d.mts +18 -0
- package/dist/math/sumBy.d.ts +18 -0
- package/dist/math/sumBy.js +45 -0
- package/dist/math/sumBy.js.map +1 -0
- package/dist/math/sumBy.mjs +9 -0
- package/dist/math/sumBy.mjs.map +1 -0
- package/dist/object/index.mjs +3 -3
- package/dist/predicate/index.mjs +3 -3
- package/dist/string/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-TLVQSNOE.mjs +0 -1
- /package/dist/{chunk-TLVQSNOE.mjs.map → chunk-FUS75PJ7.mjs.map} +0 -0
package/dist/array/index.mjs
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import "../chunk-2MRZANXZ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
without
|
|
4
|
-
} from "../chunk-PYEYV7BY.mjs";
|
|
5
|
-
import {
|
|
6
|
-
xor
|
|
7
|
-
} from "../chunk-L7FQX5MN.mjs";
|
|
8
2
|
import {
|
|
9
3
|
xorBy
|
|
10
4
|
} from "../chunk-Q47NGNXT.mjs";
|
|
@@ -20,18 +14,9 @@ import {
|
|
|
20
14
|
import {
|
|
21
15
|
zipWith
|
|
22
16
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
23
|
-
import {
|
|
24
|
-
union
|
|
25
|
-
} from "../chunk-R6QA7PLZ.mjs";
|
|
26
|
-
import {
|
|
27
|
-
unionBy
|
|
28
|
-
} from "../chunk-NFS7RWWE.mjs";
|
|
29
17
|
import {
|
|
30
18
|
unionWith
|
|
31
19
|
} from "../chunk-2ZCITDMK.mjs";
|
|
32
|
-
import {
|
|
33
|
-
uniq
|
|
34
|
-
} from "../chunk-DVK2N4KC.mjs";
|
|
35
20
|
import {
|
|
36
21
|
uniqBy
|
|
37
22
|
} from "../chunk-OXAZEEGP.mjs";
|
|
@@ -45,13 +30,11 @@ import {
|
|
|
45
30
|
unzipWith
|
|
46
31
|
} from "../chunk-IFNXROZR.mjs";
|
|
47
32
|
import {
|
|
48
|
-
|
|
49
|
-
} from "../chunk-
|
|
50
|
-
import "../chunk-GIWAOOFY.mjs";
|
|
51
|
-
import "../chunk-SYWMYQYJ.mjs";
|
|
33
|
+
without
|
|
34
|
+
} from "../chunk-PYEYV7BY.mjs";
|
|
52
35
|
import {
|
|
53
|
-
|
|
54
|
-
} from "../chunk-
|
|
36
|
+
xor
|
|
37
|
+
} from "../chunk-L7FQX5MN.mjs";
|
|
55
38
|
import {
|
|
56
39
|
tail
|
|
57
40
|
} from "../chunk-OF6NM4G7.mjs";
|
|
@@ -71,11 +54,14 @@ import {
|
|
|
71
54
|
toFilled
|
|
72
55
|
} from "../chunk-OP4OAKQJ.mjs";
|
|
73
56
|
import {
|
|
74
|
-
|
|
75
|
-
} from "../chunk-
|
|
57
|
+
union
|
|
58
|
+
} from "../chunk-R6QA7PLZ.mjs";
|
|
76
59
|
import {
|
|
77
|
-
|
|
78
|
-
} from "../chunk-
|
|
60
|
+
uniq
|
|
61
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
62
|
+
import {
|
|
63
|
+
unionBy
|
|
64
|
+
} from "../chunk-NFS7RWWE.mjs";
|
|
79
65
|
import {
|
|
80
66
|
last
|
|
81
67
|
} from "../chunk-KPBQ7OUY.mjs";
|
|
@@ -95,11 +81,13 @@ import {
|
|
|
95
81
|
sample
|
|
96
82
|
} from "../chunk-2KNLZB7V.mjs";
|
|
97
83
|
import {
|
|
98
|
-
|
|
99
|
-
} from "../chunk-
|
|
84
|
+
sampleSize
|
|
85
|
+
} from "../chunk-EHSKB6DF.mjs";
|
|
86
|
+
import "../chunk-GIWAOOFY.mjs";
|
|
87
|
+
import "../chunk-SYWMYQYJ.mjs";
|
|
100
88
|
import {
|
|
101
|
-
|
|
102
|
-
} from "../chunk-
|
|
89
|
+
shuffle
|
|
90
|
+
} from "../chunk-G7UQ5PUR.mjs";
|
|
103
91
|
import {
|
|
104
92
|
groupBy
|
|
105
93
|
} from "../chunk-E6E4RZLN.mjs";
|
|
@@ -116,11 +104,11 @@ import {
|
|
|
116
104
|
intersectionBy
|
|
117
105
|
} from "../chunk-O6UXZR3U.mjs";
|
|
118
106
|
import {
|
|
119
|
-
|
|
120
|
-
} from "../chunk-
|
|
107
|
+
intersectionWith
|
|
108
|
+
} from "../chunk-XI7KRD2C.mjs";
|
|
121
109
|
import {
|
|
122
|
-
|
|
123
|
-
} from "../chunk-
|
|
110
|
+
keyBy
|
|
111
|
+
} from "../chunk-AJKZMN2V.mjs";
|
|
124
112
|
import {
|
|
125
113
|
drop
|
|
126
114
|
} from "../chunk-S3CORED5.mjs";
|
|
@@ -136,9 +124,15 @@ import {
|
|
|
136
124
|
import {
|
|
137
125
|
fill
|
|
138
126
|
} from "../chunk-C4WE4GLC.mjs";
|
|
127
|
+
import {
|
|
128
|
+
flattenDeep
|
|
129
|
+
} from "../chunk-ML727RRJ.mjs";
|
|
139
130
|
import {
|
|
140
131
|
flatten
|
|
141
132
|
} from "../chunk-33MSBDC6.mjs";
|
|
133
|
+
import {
|
|
134
|
+
forEachRight
|
|
135
|
+
} from "../chunk-IEA53J7P.mjs";
|
|
142
136
|
import {
|
|
143
137
|
chunk
|
|
144
138
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -151,6 +145,12 @@ import {
|
|
|
151
145
|
import {
|
|
152
146
|
difference
|
|
153
147
|
} from "../chunk-JPUKH67K.mjs";
|
|
148
|
+
import {
|
|
149
|
+
differenceBy
|
|
150
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
151
|
+
import {
|
|
152
|
+
differenceWith
|
|
153
|
+
} from "../chunk-6NVQAHXP.mjs";
|
|
154
154
|
import "../chunk-2HIMLZE3.mjs";
|
|
155
155
|
export {
|
|
156
156
|
chunk,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sum
|
|
3
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
4
|
+
|
|
5
|
+
// src/math/sumBy.ts
|
|
6
|
+
function sumBy(items, getValue) {
|
|
7
|
+
const nums = items.map((x) => getValue(x));
|
|
8
|
+
return sum(nums);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
sumBy
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-5L4VWRFX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/math/sumBy.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the sum of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `0`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 6\n * sumBy([], x => x.a); // Returns: 0\n */\nexport function sumBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return sum(nums);\n}\n"],"mappings":";;;;;AAiBO,SAAS,MAAS,OAAqB,UAA0C;AACtF,QAAM,OAAO,MAAM,IAAI,OAAK,SAAS,CAAC,CAAC;AAEvC,SAAO,IAAI,IAAI;AACjB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-FUS75PJ7.mjs.map
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -61,6 +61,7 @@ export { random } from '../math/random.mjs';
|
|
|
61
61
|
export { randomInt } from '../math/randomInt.mjs';
|
|
62
62
|
export { round } from '../math/round.mjs';
|
|
63
63
|
export { sum } from '../math/sum.mjs';
|
|
64
|
+
export { sumBy } from '../math/sumBy.mjs';
|
|
64
65
|
export { range } from '../math/range.mjs';
|
|
65
66
|
export { omit } from '../object/omit.mjs';
|
|
66
67
|
export { omitBy } from '../object/omitBy.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export { random } from '../math/random.js';
|
|
|
61
61
|
export { randomInt } from '../math/randomInt.js';
|
|
62
62
|
export { round } from '../math/round.js';
|
|
63
63
|
export { sum } from '../math/sum.js';
|
|
64
|
+
export { sumBy } from '../math/sumBy.js';
|
|
64
65
|
export { range } from '../math/range.js';
|
|
65
66
|
export { omit } from '../object/omit.js';
|
|
66
67
|
export { omitBy } from '../object/omitBy.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -5031,7 +5031,7 @@ var require_lodash = __commonJS({
|
|
|
5031
5031
|
function sum2(array) {
|
|
5032
5032
|
return array && array.length ? baseSum(array, identity) : 0;
|
|
5033
5033
|
}
|
|
5034
|
-
function
|
|
5034
|
+
function sumBy2(array, iteratee2) {
|
|
5035
5035
|
return array && array.length ? baseSum(array, getIteratee(iteratee2, 2)) : 0;
|
|
5036
5036
|
}
|
|
5037
5037
|
lodash.after = after;
|
|
@@ -5318,7 +5318,7 @@ var require_lodash = __commonJS({
|
|
|
5318
5318
|
lodash.startsWith = startsWith;
|
|
5319
5319
|
lodash.subtract = subtract;
|
|
5320
5320
|
lodash.sum = sum2;
|
|
5321
|
-
lodash.sumBy =
|
|
5321
|
+
lodash.sumBy = sumBy2;
|
|
5322
5322
|
lodash.template = template;
|
|
5323
5323
|
lodash.times = times;
|
|
5324
5324
|
lodash.toFinite = toFinite;
|
|
@@ -5588,6 +5588,7 @@ __export(compat_exports, {
|
|
|
5588
5588
|
shuffle: () => shuffle,
|
|
5589
5589
|
snakeCase: () => snakeCase,
|
|
5590
5590
|
sum: () => sum,
|
|
5591
|
+
sumBy: () => sumBy,
|
|
5591
5592
|
tail: () => tail,
|
|
5592
5593
|
take: () => take,
|
|
5593
5594
|
takeRight: () => takeRight,
|
|
@@ -6247,6 +6248,12 @@ function round(value, precision = 0) {
|
|
|
6247
6248
|
return Math.round(value * multiplier) / multiplier;
|
|
6248
6249
|
}
|
|
6249
6250
|
|
|
6251
|
+
// src/math/sumBy.ts
|
|
6252
|
+
function sumBy(items, getValue) {
|
|
6253
|
+
const nums = items.map((x) => getValue(x));
|
|
6254
|
+
return sum(nums);
|
|
6255
|
+
}
|
|
6256
|
+
|
|
6250
6257
|
// src/math/range.ts
|
|
6251
6258
|
function range(start, end, step) {
|
|
6252
6259
|
if (end == null) {
|
|
@@ -6540,6 +6547,7 @@ function chunk2(arr, size = 1) {
|
|
|
6540
6547
|
shuffle,
|
|
6541
6548
|
snakeCase,
|
|
6542
6549
|
sum,
|
|
6550
|
+
sumBy,
|
|
6543
6551
|
tail,
|
|
6544
6552
|
take,
|
|
6545
6553
|
takeRight,
|