es-toolkit 1.10.0-dev.205 → 1.10.0-dev.207
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/LICENSE +7 -1
- package/dist/array/index.mjs +50 -50
- 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 +82 -78
- 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 +82 -78
- 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/compat/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import "../chunk-NKLIE2OI.mjs";
|
|
2
2
|
import "../chunk-QKYYOLJ6.mjs";
|
|
3
|
+
import {
|
|
4
|
+
capitalize
|
|
5
|
+
} from "../chunk-U56ZOM7L.mjs";
|
|
3
6
|
import {
|
|
4
7
|
kebabCase
|
|
5
8
|
} from "../chunk-EYYZQFOP.mjs";
|
|
@@ -17,10 +20,10 @@ import {
|
|
|
17
20
|
camelCase
|
|
18
21
|
} from "../chunk-XGCYC4YA.mjs";
|
|
19
22
|
import "../chunk-WVQ7YVRK.mjs";
|
|
20
|
-
import {
|
|
21
|
-
capitalize
|
|
22
|
-
} from "../chunk-U56ZOM7L.mjs";
|
|
23
23
|
import "../chunk-OSOLEQLZ.mjs";
|
|
24
|
+
import {
|
|
25
|
+
clone
|
|
26
|
+
} from "../chunk-U4JGKZ56.mjs";
|
|
24
27
|
import {
|
|
25
28
|
invert
|
|
26
29
|
} from "../chunk-74WWMNZS.mjs";
|
|
@@ -37,6 +40,9 @@ import {
|
|
|
37
40
|
pickBy
|
|
38
41
|
} from "../chunk-6CLH5YZ2.mjs";
|
|
39
42
|
import "../chunk-ASJF5D6C.mjs";
|
|
43
|
+
import {
|
|
44
|
+
isEqual
|
|
45
|
+
} from "../chunk-JYSV56US.mjs";
|
|
40
46
|
import {
|
|
41
47
|
isNil
|
|
42
48
|
} from "../chunk-WMM7TZLG.mjs";
|
|
@@ -49,26 +55,11 @@ import {
|
|
|
49
55
|
import {
|
|
50
56
|
isUndefined
|
|
51
57
|
} from "../chunk-VH2PV426.mjs";
|
|
58
|
+
import "../chunk-FZEZH22H.mjs";
|
|
52
59
|
import {
|
|
53
|
-
|
|
54
|
-
} from "../chunk-
|
|
55
|
-
import
|
|
56
|
-
clone
|
|
57
|
-
} from "../chunk-U4JGKZ56.mjs";
|
|
58
|
-
import "../chunk-236H5JZJ.mjs";
|
|
59
|
-
import {
|
|
60
|
-
negate
|
|
61
|
-
} from "../chunk-BOOQBJN2.mjs";
|
|
62
|
-
import {
|
|
63
|
-
noop
|
|
64
|
-
} from "../chunk-LKXCOLNY.mjs";
|
|
65
|
-
import {
|
|
66
|
-
once
|
|
67
|
-
} from "../chunk-CMBC4MXG.mjs";
|
|
68
|
-
import {
|
|
69
|
-
throttle
|
|
70
|
-
} from "../chunk-QOJGMVVR.mjs";
|
|
71
|
-
import "../chunk-TLVQSNOE.mjs";
|
|
60
|
+
AbortError
|
|
61
|
+
} from "../chunk-DXB7EZUQ.mjs";
|
|
62
|
+
import "../chunk-FUS75PJ7.mjs";
|
|
72
63
|
import {
|
|
73
64
|
meanBy
|
|
74
65
|
} from "../chunk-IZAD2S7R.mjs";
|
|
@@ -81,6 +72,9 @@ import {
|
|
|
81
72
|
import {
|
|
82
73
|
round
|
|
83
74
|
} from "../chunk-5PMKOZ2F.mjs";
|
|
75
|
+
import {
|
|
76
|
+
sumBy
|
|
77
|
+
} from "../chunk-5L4VWRFX.mjs";
|
|
84
78
|
import {
|
|
85
79
|
sum
|
|
86
80
|
} from "../chunk-2SLTL4KL.mjs";
|
|
@@ -90,19 +84,23 @@ import {
|
|
|
90
84
|
import {
|
|
91
85
|
inRange
|
|
92
86
|
} from "../chunk-BH6HLGBA.mjs";
|
|
87
|
+
import "../chunk-236H5JZJ.mjs";
|
|
88
|
+
import {
|
|
89
|
+
once
|
|
90
|
+
} from "../chunk-CMBC4MXG.mjs";
|
|
91
|
+
import {
|
|
92
|
+
throttle
|
|
93
|
+
} from "../chunk-QOJGMVVR.mjs";
|
|
93
94
|
import {
|
|
94
95
|
debounce
|
|
95
96
|
} from "../chunk-3IP4JVLL.mjs";
|
|
96
|
-
import "../chunk-2MRZANXZ.mjs";
|
|
97
|
-
import {
|
|
98
|
-
without
|
|
99
|
-
} from "../chunk-PYEYV7BY.mjs";
|
|
100
97
|
import {
|
|
101
|
-
|
|
102
|
-
} from "../chunk-
|
|
98
|
+
negate
|
|
99
|
+
} from "../chunk-BOOQBJN2.mjs";
|
|
103
100
|
import {
|
|
104
|
-
|
|
105
|
-
} from "../chunk-
|
|
101
|
+
noop
|
|
102
|
+
} from "../chunk-LKXCOLNY.mjs";
|
|
103
|
+
import "../chunk-2MRZANXZ.mjs";
|
|
106
104
|
import {
|
|
107
105
|
xorWith
|
|
108
106
|
} from "../chunk-QRSJBBFY.mjs";
|
|
@@ -115,24 +113,9 @@ import {
|
|
|
115
113
|
import {
|
|
116
114
|
zipWith
|
|
117
115
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
118
|
-
import {
|
|
119
|
-
union
|
|
120
|
-
} from "../chunk-R6QA7PLZ.mjs";
|
|
121
|
-
import {
|
|
122
|
-
unionBy
|
|
123
|
-
} from "../chunk-NFS7RWWE.mjs";
|
|
124
|
-
import {
|
|
125
|
-
unionWith
|
|
126
|
-
} from "../chunk-2ZCITDMK.mjs";
|
|
127
|
-
import {
|
|
128
|
-
uniq
|
|
129
|
-
} from "../chunk-DVK2N4KC.mjs";
|
|
130
116
|
import {
|
|
131
117
|
uniqBy
|
|
132
118
|
} from "../chunk-OXAZEEGP.mjs";
|
|
133
|
-
import {
|
|
134
|
-
uniqWith
|
|
135
|
-
} from "../chunk-237HGSZS.mjs";
|
|
136
119
|
import {
|
|
137
120
|
unzip
|
|
138
121
|
} from "../chunk-UYZKMBDO.mjs";
|
|
@@ -140,20 +123,14 @@ import {
|
|
|
140
123
|
unzipWith
|
|
141
124
|
} from "../chunk-IFNXROZR.mjs";
|
|
142
125
|
import {
|
|
143
|
-
|
|
144
|
-
} from "../chunk-
|
|
145
|
-
import {
|
|
146
|
-
randomInt
|
|
147
|
-
} from "../chunk-GIWAOOFY.mjs";
|
|
148
|
-
import {
|
|
149
|
-
random
|
|
150
|
-
} from "../chunk-SYWMYQYJ.mjs";
|
|
126
|
+
without
|
|
127
|
+
} from "../chunk-PYEYV7BY.mjs";
|
|
151
128
|
import {
|
|
152
|
-
|
|
153
|
-
} from "../chunk-
|
|
129
|
+
xor
|
|
130
|
+
} from "../chunk-L7FQX5MN.mjs";
|
|
154
131
|
import {
|
|
155
|
-
|
|
156
|
-
} from "../chunk-
|
|
132
|
+
xorBy
|
|
133
|
+
} from "../chunk-Q47NGNXT.mjs";
|
|
157
134
|
import {
|
|
158
135
|
take
|
|
159
136
|
} from "../chunk-ME352XO7.mjs";
|
|
@@ -170,14 +147,20 @@ import {
|
|
|
170
147
|
toFilled
|
|
171
148
|
} from "../chunk-OP4OAKQJ.mjs";
|
|
172
149
|
import {
|
|
173
|
-
|
|
174
|
-
} from "../chunk-
|
|
150
|
+
union
|
|
151
|
+
} from "../chunk-R6QA7PLZ.mjs";
|
|
175
152
|
import {
|
|
176
|
-
|
|
177
|
-
} from "../chunk-
|
|
153
|
+
uniq
|
|
154
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
178
155
|
import {
|
|
179
|
-
|
|
180
|
-
} from "../chunk-
|
|
156
|
+
unionBy
|
|
157
|
+
} from "../chunk-NFS7RWWE.mjs";
|
|
158
|
+
import {
|
|
159
|
+
unionWith
|
|
160
|
+
} from "../chunk-2ZCITDMK.mjs";
|
|
161
|
+
import {
|
|
162
|
+
uniqWith
|
|
163
|
+
} from "../chunk-237HGSZS.mjs";
|
|
181
164
|
import {
|
|
182
165
|
maxBy
|
|
183
166
|
} from "../chunk-OOKNBU4V.mjs";
|
|
@@ -194,14 +177,20 @@ import {
|
|
|
194
177
|
sample
|
|
195
178
|
} from "../chunk-2KNLZB7V.mjs";
|
|
196
179
|
import {
|
|
197
|
-
|
|
198
|
-
} from "../chunk-
|
|
180
|
+
sampleSize
|
|
181
|
+
} from "../chunk-EHSKB6DF.mjs";
|
|
199
182
|
import {
|
|
200
|
-
|
|
201
|
-
} from "../chunk-
|
|
183
|
+
randomInt
|
|
184
|
+
} from "../chunk-GIWAOOFY.mjs";
|
|
202
185
|
import {
|
|
203
|
-
|
|
204
|
-
} from "../chunk-
|
|
186
|
+
random
|
|
187
|
+
} from "../chunk-SYWMYQYJ.mjs";
|
|
188
|
+
import {
|
|
189
|
+
shuffle
|
|
190
|
+
} from "../chunk-G7UQ5PUR.mjs";
|
|
191
|
+
import {
|
|
192
|
+
tail
|
|
193
|
+
} from "../chunk-OF6NM4G7.mjs";
|
|
205
194
|
import {
|
|
206
195
|
head
|
|
207
196
|
} from "../chunk-HM2JT2RX.mjs";
|
|
@@ -215,14 +204,14 @@ import {
|
|
|
215
204
|
intersectionBy
|
|
216
205
|
} from "../chunk-O6UXZR3U.mjs";
|
|
217
206
|
import {
|
|
218
|
-
|
|
219
|
-
} from "../chunk-
|
|
207
|
+
intersectionWith
|
|
208
|
+
} from "../chunk-XI7KRD2C.mjs";
|
|
220
209
|
import {
|
|
221
|
-
|
|
222
|
-
} from "../chunk-
|
|
210
|
+
keyBy
|
|
211
|
+
} from "../chunk-AJKZMN2V.mjs";
|
|
223
212
|
import {
|
|
224
|
-
|
|
225
|
-
} from "../chunk-
|
|
213
|
+
last
|
|
214
|
+
} from "../chunk-KPBQ7OUY.mjs";
|
|
226
215
|
import {
|
|
227
216
|
dropRight
|
|
228
217
|
} from "../chunk-JEKUA56R.mjs";
|
|
@@ -235,13 +224,18 @@ import {
|
|
|
235
224
|
import {
|
|
236
225
|
fill
|
|
237
226
|
} from "../chunk-C4WE4GLC.mjs";
|
|
227
|
+
import {
|
|
228
|
+
flattenDeep
|
|
229
|
+
} from "../chunk-ML727RRJ.mjs";
|
|
238
230
|
import {
|
|
239
231
|
flatten
|
|
240
232
|
} from "../chunk-33MSBDC6.mjs";
|
|
241
|
-
import "../chunk-FZEZH22H.mjs";
|
|
242
233
|
import {
|
|
243
|
-
|
|
244
|
-
} from "../chunk-
|
|
234
|
+
forEachRight
|
|
235
|
+
} from "../chunk-IEA53J7P.mjs";
|
|
236
|
+
import {
|
|
237
|
+
groupBy
|
|
238
|
+
} from "../chunk-E6E4RZLN.mjs";
|
|
245
239
|
import {
|
|
246
240
|
chunk
|
|
247
241
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -254,6 +248,15 @@ import {
|
|
|
254
248
|
import {
|
|
255
249
|
difference
|
|
256
250
|
} from "../chunk-JPUKH67K.mjs";
|
|
251
|
+
import {
|
|
252
|
+
differenceBy
|
|
253
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
254
|
+
import {
|
|
255
|
+
differenceWith
|
|
256
|
+
} from "../chunk-6NVQAHXP.mjs";
|
|
257
|
+
import {
|
|
258
|
+
drop
|
|
259
|
+
} from "../chunk-S3CORED5.mjs";
|
|
257
260
|
import "../chunk-2HIMLZE3.mjs";
|
|
258
261
|
|
|
259
262
|
// src/compat/array/chunk.ts
|
|
@@ -325,6 +328,7 @@ export {
|
|
|
325
328
|
shuffle,
|
|
326
329
|
snakeCase,
|
|
327
330
|
sum,
|
|
331
|
+
sumBy,
|
|
328
332
|
tail,
|
|
329
333
|
take,
|
|
330
334
|
takeRight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAASA,OAAS,KAAmB,OAAe,GAAU;AACnE,SAAO,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC;AAEnC,MAAI,SAAS,GAAG;AACd,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAa,KAAK,IAAI;AAC/B;","names":["chunk"]}
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import "../chunk-236H5JZJ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
negate
|
|
4
|
-
} from "../chunk-BOOQBJN2.mjs";
|
|
5
|
-
import {
|
|
6
|
-
noop
|
|
7
|
-
} from "../chunk-LKXCOLNY.mjs";
|
|
8
2
|
import {
|
|
9
3
|
once
|
|
10
4
|
} from "../chunk-CMBC4MXG.mjs";
|
|
@@ -14,6 +8,12 @@ import {
|
|
|
14
8
|
import {
|
|
15
9
|
debounce
|
|
16
10
|
} from "../chunk-3IP4JVLL.mjs";
|
|
11
|
+
import {
|
|
12
|
+
negate
|
|
13
|
+
} from "../chunk-BOOQBJN2.mjs";
|
|
14
|
+
import {
|
|
15
|
+
noop
|
|
16
|
+
} from "../chunk-LKXCOLNY.mjs";
|
|
17
17
|
import "../chunk-2HIMLZE3.mjs";
|
|
18
18
|
export {
|
|
19
19
|
debounce,
|
package/dist/index.d.mts
CHANGED
|
@@ -62,6 +62,7 @@ export { random } from './math/random.mjs';
|
|
|
62
62
|
export { randomInt } from './math/randomInt.mjs';
|
|
63
63
|
export { round } from './math/round.mjs';
|
|
64
64
|
export { sum } from './math/sum.mjs';
|
|
65
|
+
export { sumBy } from './math/sumBy.mjs';
|
|
65
66
|
export { range } from './math/range.mjs';
|
|
66
67
|
export { omit } from './object/omit.mjs';
|
|
67
68
|
export { omitBy } from './object/omitBy.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export { random } from './math/random.js';
|
|
|
62
62
|
export { randomInt } from './math/randomInt.js';
|
|
63
63
|
export { round } from './math/round.js';
|
|
64
64
|
export { sum } from './math/sum.js';
|
|
65
|
+
export { sumBy } from './math/sumBy.js';
|
|
65
66
|
export { range } from './math/range.js';
|
|
66
67
|
export { omit } from './object/omit.js';
|
|
67
68
|
export { omitBy } from './object/omitBy.js';
|
package/dist/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(src_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) {
|
|
@@ -6531,6 +6538,7 @@ var capitalize2 = (str) => {
|
|
|
6531
6538
|
shuffle,
|
|
6532
6539
|
snakeCase,
|
|
6533
6540
|
sum,
|
|
6541
|
+
sumBy,
|
|
6534
6542
|
tail,
|
|
6535
6543
|
take,
|
|
6536
6544
|
takeRight,
|