es-toolkit 1.12.0 → 1.13.0

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.
Files changed (171) hide show
  1. package/CHANGELOG.md +16 -5
  2. package/dist/array/chunk.mjs +1 -1
  3. package/dist/array/compact.mjs +1 -1
  4. package/dist/array/countBy.mjs +1 -1
  5. package/dist/array/difference.mjs +1 -1
  6. package/dist/array/differenceBy.mjs +1 -1
  7. package/dist/array/differenceWith.mjs +1 -1
  8. package/dist/array/drop.mjs +1 -1
  9. package/dist/array/dropRight.mjs +1 -1
  10. package/dist/array/dropRightWhile.mjs +1 -1
  11. package/dist/array/dropWhile.mjs +1 -1
  12. package/dist/array/fill.mjs +1 -1
  13. package/dist/array/flatMap.mjs +1 -1
  14. package/dist/array/flatten.mjs +1 -1
  15. package/dist/array/flattenDeep.mjs +1 -1
  16. package/dist/array/forEachRight.mjs +1 -1
  17. package/dist/array/groupBy.mjs +1 -1
  18. package/dist/array/head.mjs +1 -1
  19. package/dist/array/index.js.map +1 -1
  20. package/dist/array/index.mjs +14 -14
  21. package/dist/array/initial.mjs +1 -1
  22. package/dist/array/intersection.mjs +1 -1
  23. package/dist/array/intersectionBy.mjs +1 -1
  24. package/dist/array/intersectionWith.mjs +1 -1
  25. package/dist/array/keyBy.mjs +1 -1
  26. package/dist/array/last.mjs +1 -1
  27. package/dist/array/maxBy.mjs +1 -1
  28. package/dist/array/minBy.mjs +1 -1
  29. package/dist/array/orderBy.mjs +1 -1
  30. package/dist/array/partition.mjs +1 -1
  31. package/dist/array/sample.mjs +1 -1
  32. package/dist/array/sampleSize.mjs +1 -1
  33. package/dist/array/shuffle.mjs +1 -1
  34. package/dist/array/tail.d.mts +24 -0
  35. package/dist/array/tail.d.ts +24 -0
  36. package/dist/array/tail.js.map +1 -1
  37. package/dist/array/tail.mjs +2 -2
  38. package/dist/array/take.mjs +1 -1
  39. package/dist/array/takeRight.mjs +1 -1
  40. package/dist/array/takeRightWhile.mjs +1 -1
  41. package/dist/array/takeWhile.mjs +1 -1
  42. package/dist/array/toFilled.mjs +1 -1
  43. package/dist/array/union.mjs +1 -1
  44. package/dist/array/unionBy.mjs +1 -1
  45. package/dist/array/unionWith.mjs +1 -1
  46. package/dist/array/uniq.mjs +1 -1
  47. package/dist/array/uniqBy.mjs +1 -1
  48. package/dist/array/uniqWith.mjs +1 -1
  49. package/dist/array/unzip.mjs +1 -1
  50. package/dist/array/unzipWith.mjs +1 -1
  51. package/dist/array/without.mjs +1 -1
  52. package/dist/array/xor.mjs +1 -1
  53. package/dist/array/xorBy.mjs +1 -1
  54. package/dist/array/xorWith.mjs +1 -1
  55. package/dist/array/zip.mjs +1 -1
  56. package/dist/array/zipObject.mjs +1 -1
  57. package/dist/array/zipWith.mjs +1 -1
  58. package/dist/browser.d.mts +2 -0
  59. package/dist/browser.d.ts +2 -0
  60. package/dist/browser.js +1108 -0
  61. package/dist/browser.js.map +1 -0
  62. package/dist/browser.mjs +108 -0
  63. package/dist/browser.mjs.map +1 -0
  64. package/dist/{chunk-424M7IR7.mjs → chunk-24FKGR6U.mjs} +6 -1
  65. package/dist/chunk-27QMXBLJ.mjs +9 -0
  66. package/dist/chunk-27QMXBLJ.mjs.map +1 -0
  67. package/dist/chunk-54TK5BIS.mjs +1 -0
  68. package/dist/chunk-B645AYL4.mjs +1 -0
  69. package/dist/{chunk-J3GE7DEU.mjs → chunk-CVVZHOJX.mjs} +2 -2
  70. package/dist/{chunk-XWPCDIFC.mjs → chunk-IIDZ3KAJ.mjs} +3 -3
  71. package/dist/chunk-MIGAC7F4.mjs +25 -0
  72. package/dist/chunk-MIGAC7F4.mjs.map +1 -0
  73. package/dist/chunk-SPKLWVNJ.mjs +373 -0
  74. package/dist/chunk-SPKLWVNJ.mjs.map +1 -0
  75. package/dist/{chunk-OF6NM4G7.mjs → chunk-TJ4Z5I7M.mjs} +1 -1
  76. package/dist/{chunk-OF6NM4G7.mjs.map → chunk-TJ4Z5I7M.mjs.map} +1 -1
  77. package/dist/{chunk-U7V3G7CR.mjs → chunk-WFZXCGEG.mjs} +2 -2
  78. package/dist/chunk-XGQWTHW6.mjs +34 -0
  79. package/dist/chunk-XGQWTHW6.mjs.map +1 -0
  80. package/dist/compat/index.d.mts +59 -3
  81. package/dist/compat/index.d.ts +59 -3
  82. package/dist/compat/index.js +105 -1
  83. package/dist/compat/index.js.map +1 -1
  84. package/dist/compat/index.mjs +105 -51
  85. package/dist/compat/index.mjs.map +1 -1
  86. package/dist/error/AbortError.mjs +1 -1
  87. package/dist/error/TimeoutError.mjs +1 -1
  88. package/dist/error/index.mjs +1 -1
  89. package/dist/function/debounce.mjs +1 -1
  90. package/dist/function/index.mjs +4 -4
  91. package/dist/function/negate.mjs +1 -1
  92. package/dist/function/noop.mjs +1 -1
  93. package/dist/function/once.mjs +1 -1
  94. package/dist/function/throttle.mjs +1 -1
  95. package/dist/index.d.mts +3 -0
  96. package/dist/index.d.ts +3 -0
  97. package/dist/index.js +58 -0
  98. package/dist/index.js.map +1 -1
  99. package/dist/index.mjs +62 -50
  100. package/dist/math/clamp.mjs +1 -1
  101. package/dist/math/inRange.mjs +1 -1
  102. package/dist/math/index.mjs +7 -7
  103. package/dist/math/mean.mjs +1 -1
  104. package/dist/math/meanBy.mjs +1 -1
  105. package/dist/math/random.mjs +1 -1
  106. package/dist/math/randomInt.mjs +1 -1
  107. package/dist/math/range.mjs +1 -1
  108. package/dist/math/round.mjs +1 -1
  109. package/dist/math/sum.mjs +1 -1
  110. package/dist/math/sumBy.mjs +1 -1
  111. package/dist/object/clone.mjs +1 -1
  112. package/dist/object/flattenObject.d.mts +28 -0
  113. package/dist/object/flattenObject.d.ts +28 -0
  114. package/dist/object/flattenObject.js +77 -0
  115. package/dist/object/flattenObject.js.map +1 -0
  116. package/dist/object/flattenObject.mjs +9 -0
  117. package/dist/object/index.d.mts +1 -0
  118. package/dist/object/index.d.ts +1 -0
  119. package/dist/object/index.js +49 -0
  120. package/dist/object/index.js.map +1 -1
  121. package/dist/object/index.mjs +14 -9
  122. package/dist/object/invert.mjs +1 -1
  123. package/dist/object/omit.mjs +2 -2
  124. package/dist/object/omitBy.mjs +1 -1
  125. package/dist/object/pick.mjs +1 -1
  126. package/dist/object/pickBy.mjs +1 -1
  127. package/dist/predicate/index.d.mts +2 -0
  128. package/dist/predicate/index.d.ts +2 -0
  129. package/dist/predicate/index.js +30 -0
  130. package/dist/predicate/index.js.map +1 -1
  131. package/dist/predicate/index.mjs +15 -7
  132. package/dist/predicate/isEqual.mjs +1 -1
  133. package/dist/predicate/isLength.d.mts +3 -0
  134. package/dist/predicate/isLength.d.ts +3 -0
  135. package/dist/predicate/isLength.js +33 -0
  136. package/dist/predicate/isLength.js.map +1 -0
  137. package/dist/predicate/isLength.mjs +8 -0
  138. package/dist/predicate/isLength.mjs.map +1 -0
  139. package/dist/predicate/isNil.mjs +1 -1
  140. package/dist/predicate/isNotNil.mjs +1 -1
  141. package/dist/predicate/isNull.mjs +1 -1
  142. package/dist/predicate/isPlainObject.d.mts +16 -0
  143. package/dist/predicate/isPlainObject.d.ts +16 -0
  144. package/dist/predicate/isPlainObject.js +49 -0
  145. package/dist/predicate/isPlainObject.js.map +1 -0
  146. package/dist/predicate/isPlainObject.mjs +8 -0
  147. package/dist/predicate/isPlainObject.mjs.map +1 -0
  148. package/dist/predicate/isUndefined.mjs +1 -1
  149. package/dist/promise/delay.mjs +1 -1
  150. package/dist/promise/index.mjs +3 -3
  151. package/dist/promise/timeout.mjs +2 -2
  152. package/dist/promise/withTimeout.mjs +3 -3
  153. package/dist/string/camelCase.mjs +1 -1
  154. package/dist/string/capitalize.mjs +1 -1
  155. package/dist/string/index.mjs +7 -7
  156. package/dist/string/kebabCase.mjs +1 -1
  157. package/dist/string/lowerCase.mjs +1 -1
  158. package/dist/string/snakeCase.mjs +1 -1
  159. package/dist/string/startCase.mjs +1 -1
  160. package/package.json +3 -1
  161. package/umd/browser.global.js +2 -0
  162. package/dist/chunk-ASJF5D6C.mjs +0 -1
  163. package/dist/chunk-NKLIE2OI.mjs +0 -1
  164. package/dist/chunk-OSOLEQLZ.mjs +0 -1
  165. /package/dist/{chunk-424M7IR7.mjs.map → chunk-24FKGR6U.mjs.map} +0 -0
  166. /package/dist/{chunk-ASJF5D6C.mjs.map → chunk-54TK5BIS.mjs.map} +0 -0
  167. /package/dist/{chunk-NKLIE2OI.mjs.map → chunk-B645AYL4.mjs.map} +0 -0
  168. /package/dist/{chunk-J3GE7DEU.mjs.map → chunk-CVVZHOJX.mjs.map} +0 -0
  169. /package/dist/{chunk-XWPCDIFC.mjs.map → chunk-IIDZ3KAJ.mjs.map} +0 -0
  170. /package/dist/{chunk-U7V3G7CR.mjs.map → chunk-WFZXCGEG.mjs.map} +0 -0
  171. /package/dist/{chunk-OSOLEQLZ.mjs.map → object/flattenObject.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,71 +1,86 @@
1
- import "./chunk-NKLIE2OI.mjs";
2
- import "./chunk-4OIZM4HS.mjs";
3
- import {
4
- withTimeout
5
- } from "./chunk-XWPCDIFC.mjs";
6
- import "./chunk-J3GE7DEU.mjs";
1
+ import "./chunk-SPKLWVNJ.mjs";
7
2
  import "./chunk-XT74R35S.mjs";
3
+ import {
4
+ kebabCase
5
+ } from "./chunk-EYYZQFOP.mjs";
6
+ import {
7
+ lowerCase
8
+ } from "./chunk-5IKVJGHO.mjs";
8
9
  import {
9
10
  snakeCase
10
11
  } from "./chunk-F3WCQQET.mjs";
11
12
  import {
12
13
  startCase
13
14
  } from "./chunk-QXTNZR7B.mjs";
15
+ import "./chunk-4OIZM4HS.mjs";
16
+ import {
17
+ withTimeout
18
+ } from "./chunk-IIDZ3KAJ.mjs";
19
+ import "./chunk-CVVZHOJX.mjs";
20
+ import {
21
+ delay
22
+ } from "./chunk-O64NE2P4.mjs";
14
23
  import {
15
24
  camelCase
16
25
  } from "./chunk-Y5V7UAZZ.mjs";
17
26
  import {
18
27
  capitalize
19
28
  } from "./chunk-U56ZOM7L.mjs";
29
+ import "./chunk-WVQ7YVRK.mjs";
30
+ import "./chunk-B645AYL4.mjs";
20
31
  import {
21
- kebabCase
22
- } from "./chunk-EYYZQFOP.mjs";
32
+ isNull
33
+ } from "./chunk-AIRSKN47.mjs";
23
34
  import {
24
- lowerCase
25
- } from "./chunk-5IKVJGHO.mjs";
26
- import "./chunk-WVQ7YVRK.mjs";
27
- import "./chunk-ASJF5D6C.mjs";
35
+ isUndefined
36
+ } from "./chunk-VH2PV426.mjs";
28
37
  import {
29
38
  isEqual
30
39
  } from "./chunk-JYSV56US.mjs";
40
+ import {
41
+ isLength
42
+ } from "./chunk-27QMXBLJ.mjs";
31
43
  import {
32
44
  isNil
33
45
  } from "./chunk-WMM7TZLG.mjs";
34
46
  import {
35
47
  isNotNil
36
48
  } from "./chunk-BMRTZMRE.mjs";
49
+ import "./chunk-54TK5BIS.mjs";
37
50
  import {
38
- isNull
39
- } from "./chunk-AIRSKN47.mjs";
40
- import {
41
- isUndefined
42
- } from "./chunk-VH2PV426.mjs";
51
+ omitBy
52
+ } from "./chunk-BCTYOXT7.mjs";
43
53
  import {
44
- delay
45
- } from "./chunk-O64NE2P4.mjs";
46
- import "./chunk-OSOLEQLZ.mjs";
54
+ pick
55
+ } from "./chunk-HPFDYUGP.mjs";
47
56
  import {
48
57
  pickBy
49
58
  } from "./chunk-6CLH5YZ2.mjs";
50
59
  import {
51
60
  clone
52
61
  } from "./chunk-U4JGKZ56.mjs";
62
+ import {
63
+ flattenObject
64
+ } from "./chunk-XGQWTHW6.mjs";
65
+ import {
66
+ isPlainObject
67
+ } from "./chunk-MIGAC7F4.mjs";
53
68
  import {
54
69
  invert
55
70
  } from "./chunk-OLX53VEF.mjs";
56
71
  import {
57
72
  omit
58
- } from "./chunk-U7V3G7CR.mjs";
59
- import {
60
- omitBy
61
- } from "./chunk-BCTYOXT7.mjs";
62
- import {
63
- pick
64
- } from "./chunk-HPFDYUGP.mjs";
73
+ } from "./chunk-WFZXCGEG.mjs";
65
74
  import "./chunk-FUS75PJ7.mjs";
75
+ import {
76
+ round
77
+ } from "./chunk-5PMKOZ2F.mjs";
66
78
  import {
67
79
  sumBy
68
80
  } from "./chunk-5L4VWRFX.mjs";
81
+ import {
82
+ clamp
83
+ } from "./chunk-MLCL773E.mjs";
69
84
  import {
70
85
  inRange
71
86
  } from "./chunk-BH6HLGBA.mjs";
@@ -81,13 +96,10 @@ import {
81
96
  import {
82
97
  range
83
98
  } from "./chunk-DPH2KE6O.mjs";
84
- import {
85
- round
86
- } from "./chunk-5PMKOZ2F.mjs";
87
- import {
88
- clamp
89
- } from "./chunk-MLCL773E.mjs";
90
99
  import "./chunk-DDH7K4QM.mjs";
100
+ import {
101
+ unzipWith
102
+ } from "./chunk-IFNXROZR.mjs";
91
103
  import {
92
104
  without
93
105
  } from "./chunk-PYEYV7BY.mjs";
@@ -109,6 +121,9 @@ import {
109
121
  import {
110
122
  zipWith
111
123
  } from "./chunk-4KYXHZ4R.mjs";
124
+ import {
125
+ toFilled
126
+ } from "./chunk-OP4OAKQJ.mjs";
112
127
  import {
113
128
  union
114
129
  } from "./chunk-R6QA7PLZ.mjs";
@@ -131,8 +146,8 @@ import {
131
146
  unzip
132
147
  } from "./chunk-UYZKMBDO.mjs";
133
148
  import {
134
- unzipWith
135
- } from "./chunk-IFNXROZR.mjs";
149
+ sample
150
+ } from "./chunk-2KNLZB7V.mjs";
136
151
  import {
137
152
  sampleSize
138
153
  } from "./chunk-EHSKB6DF.mjs";
@@ -147,7 +162,7 @@ import {
147
162
  } from "./chunk-G7UQ5PUR.mjs";
148
163
  import {
149
164
  tail
150
- } from "./chunk-OF6NM4G7.mjs";
165
+ } from "./chunk-TJ4Z5I7M.mjs";
151
166
  import {
152
167
  take
153
168
  } from "./chunk-ME352XO7.mjs";
@@ -161,8 +176,8 @@ import {
161
176
  takeWhile
162
177
  } from "./chunk-2IXFGSUA.mjs";
163
178
  import {
164
- toFilled
165
- } from "./chunk-OP4OAKQJ.mjs";
179
+ intersectionBy
180
+ } from "./chunk-O6UXZR3U.mjs";
166
181
  import {
167
182
  intersectionWith
168
183
  } from "./chunk-XI7KRD2C.mjs";
@@ -184,9 +199,6 @@ import {
184
199
  import {
185
200
  partition
186
201
  } from "./chunk-DN3NOZ3H.mjs";
187
- import {
188
- sample
189
- } from "./chunk-2KNLZB7V.mjs";
190
202
  import {
191
203
  flattenDeep
192
204
  } from "./chunk-ML727RRJ.mjs";
@@ -206,8 +218,8 @@ import {
206
218
  intersection
207
219
  } from "./chunk-FVVSE2F2.mjs";
208
220
  import {
209
- intersectionBy
210
- } from "./chunk-O6UXZR3U.mjs";
221
+ differenceBy
222
+ } from "./chunk-LVWX5B43.mjs";
211
223
  import {
212
224
  differenceWith
213
225
  } from "./chunk-6NVQAHXP.mjs";
@@ -244,9 +256,6 @@ import {
244
256
  import {
245
257
  difference
246
258
  } from "./chunk-JPUKH67K.mjs";
247
- import {
248
- differenceBy
249
- } from "./chunk-LVWX5B43.mjs";
250
259
  import "./chunk-F47GLYUU.mjs";
251
260
  import {
252
261
  AbortError
@@ -255,6 +264,9 @@ import {
255
264
  TimeoutError
256
265
  } from "./chunk-KIOYQRMQ.mjs";
257
266
  import "./chunk-236H5JZJ.mjs";
267
+ import {
268
+ negate
269
+ } from "./chunk-BOOQBJN2.mjs";
258
270
  import {
259
271
  noop
260
272
  } from "./chunk-LKXCOLNY.mjs";
@@ -267,10 +279,7 @@ import {
267
279
  import {
268
280
  debounce
269
281
  } from "./chunk-3IP4JVLL.mjs";
270
- import {
271
- negate
272
- } from "./chunk-BOOQBJN2.mjs";
273
- import "./chunk-424M7IR7.mjs";
282
+ import "./chunk-24FKGR6U.mjs";
274
283
  export {
275
284
  AbortError,
276
285
  TimeoutError,
@@ -294,6 +303,7 @@ export {
294
303
  flatMap,
295
304
  flatten,
296
305
  flattenDeep,
306
+ flattenObject,
297
307
  forEachRight,
298
308
  groupBy,
299
309
  head,
@@ -304,9 +314,11 @@ export {
304
314
  intersectionWith,
305
315
  invert,
306
316
  isEqual,
317
+ isLength,
307
318
  isNil,
308
319
  isNotNil,
309
320
  isNull,
321
+ isPlainObject,
310
322
  isUndefined,
311
323
  kebabCase,
312
324
  keyBy,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  clamp
3
3
  } from "../chunk-MLCL773E.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  clamp
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  inRange
3
3
  } from "../chunk-BH6HLGBA.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  inRange
7
7
  };
@@ -1,7 +1,13 @@
1
1
  import "../chunk-FUS75PJ7.mjs";
2
+ import {
3
+ round
4
+ } from "../chunk-5PMKOZ2F.mjs";
2
5
  import {
3
6
  sumBy
4
7
  } from "../chunk-5L4VWRFX.mjs";
8
+ import {
9
+ clamp
10
+ } from "../chunk-MLCL773E.mjs";
5
11
  import {
6
12
  inRange
7
13
  } from "../chunk-BH6HLGBA.mjs";
@@ -17,19 +23,13 @@ import {
17
23
  import {
18
24
  range
19
25
  } from "../chunk-DPH2KE6O.mjs";
20
- import {
21
- round
22
- } from "../chunk-5PMKOZ2F.mjs";
23
- import {
24
- clamp
25
- } from "../chunk-MLCL773E.mjs";
26
26
  import {
27
27
  randomInt
28
28
  } from "../chunk-GIWAOOFY.mjs";
29
29
  import {
30
30
  random
31
31
  } from "../chunk-SYWMYQYJ.mjs";
32
- import "../chunk-424M7IR7.mjs";
32
+ import "../chunk-24FKGR6U.mjs";
33
33
  export {
34
34
  clamp,
35
35
  inRange,
@@ -2,7 +2,7 @@ import {
2
2
  mean
3
3
  } from "../chunk-5ASRKEB4.mjs";
4
4
  import "../chunk-2SLTL4KL.mjs";
5
- import "../chunk-424M7IR7.mjs";
5
+ import "../chunk-24FKGR6U.mjs";
6
6
  export {
7
7
  mean
8
8
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-MY4G7R3I.mjs";
4
4
  import "../chunk-5ASRKEB4.mjs";
5
5
  import "../chunk-2SLTL4KL.mjs";
6
- import "../chunk-424M7IR7.mjs";
6
+ import "../chunk-24FKGR6U.mjs";
7
7
  export {
8
8
  meanBy
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  random
3
3
  } from "../chunk-SYWMYQYJ.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  random
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  randomInt
3
3
  } from "../chunk-GIWAOOFY.mjs";
4
4
  import "../chunk-SYWMYQYJ.mjs";
5
- import "../chunk-424M7IR7.mjs";
5
+ import "../chunk-24FKGR6U.mjs";
6
6
  export {
7
7
  randomInt
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  range
3
3
  } from "../chunk-DPH2KE6O.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  range
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  round
3
3
  } from "../chunk-5PMKOZ2F.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  round
7
7
  };
package/dist/math/sum.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  sum
3
3
  } from "../chunk-2SLTL4KL.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  sum
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  sumBy
3
3
  } from "../chunk-5L4VWRFX.mjs";
4
4
  import "../chunk-2SLTL4KL.mjs";
5
- import "../chunk-424M7IR7.mjs";
5
+ import "../chunk-24FKGR6U.mjs";
6
6
  export {
7
7
  sumBy
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  clone
3
3
  } from "../chunk-U4JGKZ56.mjs";
4
- import "../chunk-424M7IR7.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
5
  export {
6
6
  clone
7
7
  };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Flattens a nested object into a single level object with dot-separated keys.
3
+ *
4
+ * @param {object} object - The object to flatten.
5
+ * @returns {Record<string, any>} - The flattened object.
6
+ *
7
+ * @example
8
+ * const nestedObject = {
9
+ * a: {
10
+ * b: {
11
+ * c: 1
12
+ * }
13
+ * },
14
+ * d: [2, 3]
15
+ * };
16
+ *
17
+ * const flattened = flattenObject(nestedObject);
18
+ * console.log(flattened);
19
+ * // Output:
20
+ * // {
21
+ * // 'a.b.c': 1,
22
+ * // 'd.0': 2,
23
+ * // 'd.1': 3
24
+ * // }
25
+ */
26
+ declare function flattenObject(object: object): Record<string, any>;
27
+
28
+ export { flattenObject };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Flattens a nested object into a single level object with dot-separated keys.
3
+ *
4
+ * @param {object} object - The object to flatten.
5
+ * @returns {Record<string, any>} - The flattened object.
6
+ *
7
+ * @example
8
+ * const nestedObject = {
9
+ * a: {
10
+ * b: {
11
+ * c: 1
12
+ * }
13
+ * },
14
+ * d: [2, 3]
15
+ * };
16
+ *
17
+ * const flattened = flattenObject(nestedObject);
18
+ * console.log(flattened);
19
+ * // Output:
20
+ * // {
21
+ * // 'a.b.c': 1,
22
+ * // 'd.0': 2,
23
+ * // 'd.1': 3
24
+ * // }
25
+ */
26
+ declare function flattenObject(object: object): Record<string, any>;
27
+
28
+ export { flattenObject };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/object/flattenObject.ts
21
+ var flattenObject_exports = {};
22
+ __export(flattenObject_exports, {
23
+ flattenObject: () => flattenObject
24
+ });
25
+ module.exports = __toCommonJS(flattenObject_exports);
26
+
27
+ // src/predicate/isPlainObject.ts
28
+ function isPlainObject(object) {
29
+ if (typeof object !== "object") {
30
+ return false;
31
+ }
32
+ if (object == null) {
33
+ return false;
34
+ }
35
+ if (Object.getPrototypeOf(object) === null) {
36
+ return true;
37
+ }
38
+ if (object.toString() !== "[object Object]") {
39
+ return false;
40
+ }
41
+ let proto = object;
42
+ while (Object.getPrototypeOf(proto) !== null) {
43
+ proto = Object.getPrototypeOf(proto);
44
+ }
45
+ return Object.getPrototypeOf(object) === proto;
46
+ }
47
+
48
+ // src/object/flattenObject.ts
49
+ function flattenObject(object) {
50
+ return flattenObjectImpl(object);
51
+ }
52
+ function flattenObjectImpl(object, prefix = "") {
53
+ const result = {};
54
+ const keys = Object.keys(object);
55
+ for (let i = 0; i < keys.length; i++) {
56
+ const key = keys[i];
57
+ const value = object[key];
58
+ const prefixedKey = prefix ? `${prefix}.${key}` : key;
59
+ if (isPlainObject(value) && Object.keys(value).length > 0) {
60
+ Object.assign(result, flattenObjectImpl(value, prefixedKey));
61
+ continue;
62
+ }
63
+ if (Array.isArray(value)) {
64
+ for (let index = 0; index < value.length; index++) {
65
+ result[`${prefixedKey}.${index}`] = value[index];
66
+ }
67
+ continue;
68
+ }
69
+ result[prefixedKey] = value;
70
+ }
71
+ return result;
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ flattenObject
76
+ });
77
+ //# sourceMappingURL=flattenObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/flattenObject.ts","../../src/predicate/isPlainObject.ts"],"sourcesContent":["import { isPlainObject } from \"../predicate/isPlainObject.ts\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n * \n * @param {object} object - The object to flatten.\n * @returns {Record<string, any>} - The flattened object.\n * \n * @example\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n * \n * const flattened = flattenObject(nestedObject);\n * console.log(flattened); \n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n */\nexport function flattenObject(object: object): Record<string, any> {\n return flattenObjectImpl(object);\n}\n\nfunction flattenObjectImpl(object: object, prefix = ''): Record<string, any> {\n const result: Record<string, any> = {};\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(result, flattenObjectImpl(value, prefixedKey));\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n result[`${prefixedKey}.${index}`] = value[index];\n }\n continue;\n }\n\n result[prefixedKey] = value;\n }\n\n return result;\n}","/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,cAAc,QAAyB;AACrD,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,MAAM,MAAM,MAAM;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;;;ADVO,SAAS,cAAc,QAAqC;AACjE,SAAO,kBAAkB,MAAM;AACjC;AAEA,SAAS,kBAAkB,QAAgB,SAAS,IAAyB;AAC3E,QAAM,SAA8B,CAAC;AACrC,QAAM,OAAO,OAAO,KAAK,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,UAAM,QAAS,OAAe,GAAG;AAEjC,UAAM,cAAc,SAAS,GAAG,MAAM,IAAI,GAAG,KAAK;AAElD,QAAI,cAAc,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,SAAS,GAAG;AACzD,aAAO,OAAO,QAAQ,kBAAkB,OAAO,WAAW,CAAC;AAC3D;AAAA,IACF;AAEA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,eAAO,GAAG,WAAW,IAAI,KAAK,EAAE,IAAI,MAAM,KAAK;AAAA,MACjD;AACA;AAAA,IACF;AAEA,WAAO,WAAW,IAAI;AAAA,EACxB;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ flattenObject
3
+ } from "../chunk-XGQWTHW6.mjs";
4
+ import "../chunk-MIGAC7F4.mjs";
5
+ import "../chunk-24FKGR6U.mjs";
6
+ export {
7
+ flattenObject
8
+ };
9
+ //# sourceMappingURL=flattenObject.mjs.map
@@ -4,3 +4,4 @@ export { pick } from './pick.mjs';
4
4
  export { pickBy } from './pickBy.mjs';
5
5
  export { invert } from './invert.mjs';
6
6
  export { clone } from './clone.mjs';
7
+ export { flattenObject } from './flattenObject.mjs';
@@ -4,3 +4,4 @@ export { pick } from './pick.js';
4
4
  export { pickBy } from './pickBy.js';
5
5
  export { invert } from './invert.js';
6
6
  export { clone } from './clone.js';
7
+ export { flattenObject } from './flattenObject.js';
@@ -35,6 +35,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
35
35
  var object_exports = {};
36
36
  __export(object_exports, {
37
37
  clone: () => clone,
38
+ flattenObject: () => flattenObject,
38
39
  invert: () => invert,
39
40
  omit: () => omit,
40
41
  omitBy: () => omitBy,
@@ -133,9 +134,57 @@ function clone(obj) {
133
134
  function isPrimitive(value) {
134
135
  return value == null || typeof value !== "object" && typeof value !== "function";
135
136
  }
137
+
138
+ // src/predicate/isPlainObject.ts
139
+ function isPlainObject(object) {
140
+ if (typeof object !== "object") {
141
+ return false;
142
+ }
143
+ if (object == null) {
144
+ return false;
145
+ }
146
+ if (Object.getPrototypeOf(object) === null) {
147
+ return true;
148
+ }
149
+ if (object.toString() !== "[object Object]") {
150
+ return false;
151
+ }
152
+ let proto = object;
153
+ while (Object.getPrototypeOf(proto) !== null) {
154
+ proto = Object.getPrototypeOf(proto);
155
+ }
156
+ return Object.getPrototypeOf(object) === proto;
157
+ }
158
+
159
+ // src/object/flattenObject.ts
160
+ function flattenObject(object) {
161
+ return flattenObjectImpl(object);
162
+ }
163
+ function flattenObjectImpl(object, prefix = "") {
164
+ const result = {};
165
+ const keys = Object.keys(object);
166
+ for (let i = 0; i < keys.length; i++) {
167
+ const key = keys[i];
168
+ const value = object[key];
169
+ const prefixedKey = prefix ? `${prefix}.${key}` : key;
170
+ if (isPlainObject(value) && Object.keys(value).length > 0) {
171
+ Object.assign(result, flattenObjectImpl(value, prefixedKey));
172
+ continue;
173
+ }
174
+ if (Array.isArray(value)) {
175
+ for (let index = 0; index < value.length; index++) {
176
+ result[`${prefixedKey}.${index}`] = value[index];
177
+ }
178
+ continue;
179
+ }
180
+ result[prefixedKey] = value;
181
+ }
182
+ return result;
183
+ }
136
184
  // Annotate the CommonJS export names for ESM import in node:
137
185
  0 && (module.exports = {
138
186
  clone,
187
+ flattenObject,
139
188
  invert,
140
189
  omit,
141
190
  omitBy,