es-toolkit 1.10.0-dev.204 → 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.
@@ -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,7 @@ import {
49
55
  import {
50
56
  isUndefined
51
57
  } from "../chunk-VH2PV426.mjs";
52
- import {
53
- isEqual
54
- } from "../chunk-JYSV56US.mjs";
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";
58
+ import "../chunk-FUS75PJ7.mjs";
72
59
  import {
73
60
  meanBy
74
61
  } from "../chunk-IZAD2S7R.mjs";
@@ -81,6 +68,9 @@ import {
81
68
  import {
82
69
  round
83
70
  } from "../chunk-5PMKOZ2F.mjs";
71
+ import {
72
+ sumBy
73
+ } from "../chunk-5L4VWRFX.mjs";
84
74
  import {
85
75
  sum
86
76
  } from "../chunk-2SLTL4KL.mjs";
@@ -90,16 +80,7 @@ import {
90
80
  import {
91
81
  inRange
92
82
  } from "../chunk-BH6HLGBA.mjs";
93
- import {
94
- debounce
95
- } from "../chunk-3IP4JVLL.mjs";
96
83
  import "../chunk-2MRZANXZ.mjs";
97
- import {
98
- without
99
- } from "../chunk-PYEYV7BY.mjs";
100
- import {
101
- xor
102
- } from "../chunk-L7FQX5MN.mjs";
103
84
  import {
104
85
  xorBy
105
86
  } from "../chunk-Q47NGNXT.mjs";
@@ -115,18 +96,9 @@ import {
115
96
  import {
116
97
  zipWith
117
98
  } from "../chunk-4KYXHZ4R.mjs";
118
- import {
119
- union
120
- } from "../chunk-R6QA7PLZ.mjs";
121
- import {
122
- unionBy
123
- } from "../chunk-NFS7RWWE.mjs";
124
99
  import {
125
100
  unionWith
126
101
  } from "../chunk-2ZCITDMK.mjs";
127
- import {
128
- uniq
129
- } from "../chunk-DVK2N4KC.mjs";
130
102
  import {
131
103
  uniqBy
132
104
  } from "../chunk-OXAZEEGP.mjs";
@@ -140,17 +112,11 @@ import {
140
112
  unzipWith
141
113
  } from "../chunk-IFNXROZR.mjs";
142
114
  import {
143
- sampleSize
144
- } from "../chunk-EHSKB6DF.mjs";
145
- import {
146
- randomInt
147
- } from "../chunk-GIWAOOFY.mjs";
148
- import {
149
- random
150
- } from "../chunk-SYWMYQYJ.mjs";
115
+ without
116
+ } from "../chunk-PYEYV7BY.mjs";
151
117
  import {
152
- shuffle
153
- } from "../chunk-G7UQ5PUR.mjs";
118
+ xor
119
+ } from "../chunk-L7FQX5MN.mjs";
154
120
  import {
155
121
  tail
156
122
  } from "../chunk-OF6NM4G7.mjs";
@@ -170,11 +136,14 @@ import {
170
136
  toFilled
171
137
  } from "../chunk-OP4OAKQJ.mjs";
172
138
  import {
173
- intersectionWith
174
- } from "../chunk-XI7KRD2C.mjs";
139
+ union
140
+ } from "../chunk-R6QA7PLZ.mjs";
175
141
  import {
176
- keyBy
177
- } from "../chunk-AJKZMN2V.mjs";
142
+ uniq
143
+ } from "../chunk-DVK2N4KC.mjs";
144
+ import {
145
+ unionBy
146
+ } from "../chunk-NFS7RWWE.mjs";
178
147
  import {
179
148
  last
180
149
  } from "../chunk-KPBQ7OUY.mjs";
@@ -194,11 +163,17 @@ import {
194
163
  sample
195
164
  } from "../chunk-2KNLZB7V.mjs";
196
165
  import {
197
- flattenDeep
198
- } from "../chunk-ML727RRJ.mjs";
166
+ sampleSize
167
+ } from "../chunk-EHSKB6DF.mjs";
199
168
  import {
200
- forEachRight
201
- } from "../chunk-IEA53J7P.mjs";
169
+ randomInt
170
+ } from "../chunk-GIWAOOFY.mjs";
171
+ import {
172
+ random
173
+ } from "../chunk-SYWMYQYJ.mjs";
174
+ import {
175
+ shuffle
176
+ } from "../chunk-G7UQ5PUR.mjs";
202
177
  import {
203
178
  groupBy
204
179
  } from "../chunk-E6E4RZLN.mjs";
@@ -215,11 +190,11 @@ import {
215
190
  intersectionBy
216
191
  } from "../chunk-O6UXZR3U.mjs";
217
192
  import {
218
- differenceBy
219
- } from "../chunk-LVWX5B43.mjs";
193
+ intersectionWith
194
+ } from "../chunk-XI7KRD2C.mjs";
220
195
  import {
221
- differenceWith
222
- } from "../chunk-6NVQAHXP.mjs";
196
+ keyBy
197
+ } from "../chunk-AJKZMN2V.mjs";
223
198
  import {
224
199
  drop
225
200
  } from "../chunk-S3CORED5.mjs";
@@ -235,13 +210,15 @@ import {
235
210
  import {
236
211
  fill
237
212
  } from "../chunk-C4WE4GLC.mjs";
213
+ import {
214
+ flattenDeep
215
+ } from "../chunk-ML727RRJ.mjs";
238
216
  import {
239
217
  flatten
240
218
  } from "../chunk-33MSBDC6.mjs";
241
- import "../chunk-FZEZH22H.mjs";
242
219
  import {
243
- AbortError
244
- } from "../chunk-DXB7EZUQ.mjs";
220
+ forEachRight
221
+ } from "../chunk-IEA53J7P.mjs";
245
222
  import {
246
223
  chunk
247
224
  } from "../chunk-E6C5EZQA.mjs";
@@ -254,6 +231,32 @@ import {
254
231
  import {
255
232
  difference
256
233
  } from "../chunk-JPUKH67K.mjs";
234
+ import {
235
+ differenceBy
236
+ } from "../chunk-LVWX5B43.mjs";
237
+ import {
238
+ differenceWith
239
+ } from "../chunk-6NVQAHXP.mjs";
240
+ import "../chunk-FZEZH22H.mjs";
241
+ import {
242
+ AbortError
243
+ } from "../chunk-DXB7EZUQ.mjs";
244
+ import "../chunk-236H5JZJ.mjs";
245
+ import {
246
+ once
247
+ } from "../chunk-CMBC4MXG.mjs";
248
+ import {
249
+ throttle
250
+ } from "../chunk-QOJGMVVR.mjs";
251
+ import {
252
+ debounce
253
+ } from "../chunk-3IP4JVLL.mjs";
254
+ import {
255
+ negate
256
+ } from "../chunk-BOOQBJN2.mjs";
257
+ import {
258
+ noop
259
+ } from "../chunk-LKXCOLNY.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
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"]}
@@ -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 sumBy(array, iteratee2) {
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 = 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,