es-toolkit 1.10.1-dev.219 → 1.10.1-dev.220

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,11 @@
1
1
  import "../chunk-NKLIE2OI.mjs";
2
2
  import "../chunk-QKYYOLJ6.mjs";
3
+ import {
4
+ camelCase
5
+ } from "../chunk-Y5V7UAZZ.mjs";
6
+ import {
7
+ capitalize
8
+ } from "../chunk-U56ZOM7L.mjs";
3
9
  import {
4
10
  kebabCase
5
11
  } from "../chunk-EYYZQFOP.mjs";
@@ -9,17 +15,27 @@ import {
9
15
  import {
10
16
  snakeCase
11
17
  } from "../chunk-F3WCQQET.mjs";
18
+ import "../chunk-WVQ7YVRK.mjs";
19
+ import "../chunk-ASJF5D6C.mjs";
20
+ import {
21
+ isEqual
22
+ } from "../chunk-JYSV56US.mjs";
23
+ import {
24
+ isNil
25
+ } from "../chunk-WMM7TZLG.mjs";
26
+ import {
27
+ isNotNil
28
+ } from "../chunk-BMRTZMRE.mjs";
29
+ import {
30
+ isNull
31
+ } from "../chunk-AIRSKN47.mjs";
32
+ import {
33
+ isUndefined
34
+ } from "../chunk-VH2PV426.mjs";
12
35
  import "../chunk-ARZ5BDR6.mjs";
13
36
  import {
14
37
  delay
15
38
  } from "../chunk-O64NE2P4.mjs";
16
- import {
17
- camelCase
18
- } from "../chunk-Y5V7UAZZ.mjs";
19
- import {
20
- capitalize
21
- } from "../chunk-U56ZOM7L.mjs";
22
- import "../chunk-WVQ7YVRK.mjs";
23
39
  import "../chunk-OSOLEQLZ.mjs";
24
40
  import {
25
41
  clone
@@ -39,23 +55,10 @@ import {
39
55
  import {
40
56
  pickBy
41
57
  } from "../chunk-6CLH5YZ2.mjs";
42
- import "../chunk-ASJF5D6C.mjs";
43
- import {
44
- isEqual
45
- } from "../chunk-JYSV56US.mjs";
46
- import {
47
- isNil
48
- } from "../chunk-WMM7TZLG.mjs";
49
- import {
50
- isNotNil
51
- } from "../chunk-BMRTZMRE.mjs";
52
- import {
53
- isNull
54
- } from "../chunk-AIRSKN47.mjs";
55
- import {
56
- isUndefined
57
- } from "../chunk-VH2PV426.mjs";
58
58
  import "../chunk-FUS75PJ7.mjs";
59
+ import {
60
+ sumBy
61
+ } from "../chunk-5L4VWRFX.mjs";
59
62
  import {
60
63
  meanBy
61
64
  } from "../chunk-IZAD2S7R.mjs";
@@ -68,9 +71,6 @@ import {
68
71
  import {
69
72
  round
70
73
  } from "../chunk-5PMKOZ2F.mjs";
71
- import {
72
- sumBy
73
- } from "../chunk-5L4VWRFX.mjs";
74
74
  import {
75
75
  sum
76
76
  } from "../chunk-2SLTL4KL.mjs";
@@ -80,7 +80,10 @@ import {
80
80
  import {
81
81
  inRange
82
82
  } from "../chunk-BH6HLGBA.mjs";
83
- import "../chunk-2MRZANXZ.mjs";
83
+ import "../chunk-DDH7K4QM.mjs";
84
+ import {
85
+ xor
86
+ } from "../chunk-L7FQX5MN.mjs";
84
87
  import {
85
88
  xorBy
86
89
  } from "../chunk-Q47NGNXT.mjs";
@@ -96,6 +99,9 @@ import {
96
99
  import {
97
100
  zipWith
98
101
  } from "../chunk-4KYXHZ4R.mjs";
102
+ import {
103
+ unionBy
104
+ } from "../chunk-NFS7RWWE.mjs";
99
105
  import {
100
106
  unionWith
101
107
  } from "../chunk-2ZCITDMK.mjs";
@@ -115,8 +121,8 @@ import {
115
121
  without
116
122
  } from "../chunk-PYEYV7BY.mjs";
117
123
  import {
118
- xor
119
- } from "../chunk-L7FQX5MN.mjs";
124
+ shuffle
125
+ } from "../chunk-G7UQ5PUR.mjs";
120
126
  import {
121
127
  tail
122
128
  } from "../chunk-OF6NM4G7.mjs";
@@ -142,8 +148,8 @@ import {
142
148
  uniq
143
149
  } from "../chunk-DVK2N4KC.mjs";
144
150
  import {
145
- unionBy
146
- } from "../chunk-NFS7RWWE.mjs";
151
+ keyBy
152
+ } from "../chunk-AJKZMN2V.mjs";
147
153
  import {
148
154
  last
149
155
  } from "../chunk-KPBQ7OUY.mjs";
@@ -172,8 +178,8 @@ import {
172
178
  random
173
179
  } from "../chunk-SYWMYQYJ.mjs";
174
180
  import {
175
- shuffle
176
- } from "../chunk-G7UQ5PUR.mjs";
181
+ forEachRight
182
+ } from "../chunk-IEA53J7P.mjs";
177
183
  import {
178
184
  groupBy
179
185
  } from "../chunk-E6E4RZLN.mjs";
@@ -192,9 +198,6 @@ import {
192
198
  import {
193
199
  intersectionWith
194
200
  } from "../chunk-XI7KRD2C.mjs";
195
- import {
196
- keyBy
197
- } from "../chunk-AJKZMN2V.mjs";
198
201
  import {
199
202
  drop
200
203
  } from "../chunk-S3CORED5.mjs";
@@ -210,15 +213,15 @@ import {
210
213
  import {
211
214
  fill
212
215
  } from "../chunk-6KP7CLVJ.mjs";
216
+ import {
217
+ flatMap
218
+ } from "../chunk-KBXHURLW.mjs";
213
219
  import {
214
220
  flattenDeep
215
221
  } from "../chunk-ML727RRJ.mjs";
216
222
  import {
217
223
  flatten
218
224
  } from "../chunk-33MSBDC6.mjs";
219
- import {
220
- forEachRight
221
- } from "../chunk-IEA53J7P.mjs";
222
225
  import {
223
226
  chunk
224
227
  } from "../chunk-E6C5EZQA.mjs";
@@ -286,6 +289,7 @@ export {
286
289
  dropRightWhile,
287
290
  dropWhile,
288
291
  fill,
292
+ flatMap,
289
293
  flatten,
290
294
  flattenDeep,
291
295
  forEachRight,
@@ -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"]}
package/dist/index.d.mts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.mjs';
9
9
  export { dropRightWhile } from './array/dropRightWhile.mjs';
10
10
  export { dropWhile } from './array/dropWhile.mjs';
11
11
  export { fill } from './array/fill.mjs';
12
+ export { flatMap } from './array/flatMap.mjs';
12
13
  export { flatten } from './array/flatten.mjs';
13
14
  export { flattenDeep } from './array/flattenDeep.mjs';
14
15
  export { forEachRight } from './array/forEachRight.mjs';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.js';
9
9
  export { dropRightWhile } from './array/dropRightWhile.js';
10
10
  export { dropWhile } from './array/dropWhile.js';
11
11
  export { fill } from './array/fill.js';
12
+ export { flatMap } from './array/flatMap.js';
12
13
  export { flatten } from './array/flatten.js';
13
14
  export { flattenDeep } from './array/flattenDeep.js';
14
15
  export { forEachRight } from './array/forEachRight.js';
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ __export(src_exports, {
52
52
  dropRightWhile: () => dropRightWhile,
53
53
  dropWhile: () => dropWhile,
54
54
  fill: () => fill,
55
+ flatMap: () => flatMap,
55
56
  flatten: () => flatten,
56
57
  flattenDeep: () => flattenDeep,
57
58
  forEachRight: () => forEachRight,
@@ -233,6 +234,11 @@ function flatten(arr, depth = 1) {
233
234
  return result;
234
235
  }
235
236
 
237
+ // src/array/flatMap.ts
238
+ function flatMap(arr, iteratee, depth = 1) {
239
+ return flatten(arr.map((item) => iteratee(item)), depth);
240
+ }
241
+
236
242
  // src/array/flattenDeep.ts
237
243
  function flattenDeep(arr) {
238
244
  return flatten(arr, Infinity);
@@ -999,6 +1005,7 @@ var lowerCase = (str) => {
999
1005
  dropRightWhile,
1000
1006
  dropWhile,
1001
1007
  fill,
1008
+ flatMap,
1002
1009
  flatten,
1003
1010
  flattenDeep,
1004
1011
  forEachRight,