es-toolkit 1.13.1-dev.317 → 1.13.1-dev.318

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 (38) hide show
  1. package/dist/array/index.mjs +16 -16
  2. package/dist/browser.js +90 -0
  3. package/dist/browser.js.map +1 -1
  4. package/dist/browser.mjs +25 -24
  5. package/dist/browser.mjs.map +1 -1
  6. package/dist/{chunk-HKO7DEJK.mjs → chunk-36ZJSTNA.mjs} +54 -50
  7. package/dist/{chunk-HKO7DEJK.mjs.map → chunk-36ZJSTNA.mjs.map} +1 -1
  8. package/dist/chunk-5CPXZFCB.mjs +93 -0
  9. package/dist/chunk-5CPXZFCB.mjs.map +1 -0
  10. package/dist/chunk-YXAOYIRV.mjs +1 -0
  11. package/dist/compat/index.d.mts +1 -0
  12. package/dist/compat/index.d.ts +1 -0
  13. package/dist/compat/index.js +91 -0
  14. package/dist/compat/index.js.map +1 -1
  15. package/dist/compat/index.mjs +56 -52
  16. package/dist/function/index.mjs +9 -9
  17. package/dist/index.d.mts +1 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +91 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +57 -53
  22. package/dist/object/cloneDeep.d.mts +64 -0
  23. package/dist/object/cloneDeep.d.ts +64 -0
  24. package/dist/object/cloneDeep.js +117 -0
  25. package/dist/object/cloneDeep.js.map +1 -0
  26. package/dist/object/cloneDeep.mjs +8 -0
  27. package/dist/object/cloneDeep.mjs.map +1 -0
  28. package/dist/object/index.d.mts +1 -0
  29. package/dist/object/index.d.ts +1 -0
  30. package/dist/object/index.js +91 -0
  31. package/dist/object/index.js.map +1 -1
  32. package/dist/object/index.mjs +8 -4
  33. package/dist/predicate/index.mjs +3 -3
  34. package/dist/string/index.mjs +3 -3
  35. package/package.json +1 -1
  36. package/umd/browser.global.js +1 -1
  37. package/dist/chunk-54TK5BIS.mjs +0 -1
  38. /package/dist/{chunk-54TK5BIS.mjs.map → chunk-YXAOYIRV.mjs.map} +0 -0
@@ -12,9 +12,17 @@ import {
12
12
  set,
13
13
  startsWith,
14
14
  zipObjectDeep
15
- } from "../chunk-HKO7DEJK.mjs";
15
+ } from "../chunk-36ZJSTNA.mjs";
16
16
  import "../chunk-NKLIE2OI.mjs";
17
+ import "../chunk-4OIZM4HS.mjs";
18
+ import {
19
+ withTimeout
20
+ } from "../chunk-IIDZ3KAJ.mjs";
21
+ import "../chunk-CVVZHOJX.mjs";
17
22
  import "../chunk-XT74R35S.mjs";
23
+ import {
24
+ snakeCase
25
+ } from "../chunk-F3WCQQET.mjs";
18
26
  import {
19
27
  startCase
20
28
  } from "../chunk-QXTNZR7B.mjs";
@@ -30,19 +38,14 @@ import {
30
38
  import {
31
39
  lowerCase
32
40
  } from "../chunk-5IKVJGHO.mjs";
33
- import {
34
- snakeCase
35
- } from "../chunk-F3WCQQET.mjs";
36
41
  import "../chunk-WVQ7YVRK.mjs";
37
- import "../chunk-4OIZM4HS.mjs";
38
- import {
39
- withTimeout
40
- } from "../chunk-IIDZ3KAJ.mjs";
41
- import "../chunk-CVVZHOJX.mjs";
42
42
  import {
43
43
  delay
44
44
  } from "../chunk-O64NE2P4.mjs";
45
45
  import "../chunk-U4JWMVQK.mjs";
46
+ import {
47
+ isFunction
48
+ } from "../chunk-74CREQXW.mjs";
46
49
  import {
47
50
  isNil
48
51
  } from "../chunk-WMM7TZLG.mjs";
@@ -64,10 +67,10 @@ import {
64
67
  import {
65
68
  isEqual
66
69
  } from "../chunk-JYSV56US.mjs";
70
+ import "../chunk-YXAOYIRV.mjs";
67
71
  import {
68
- isFunction
69
- } from "../chunk-74CREQXW.mjs";
70
- import "../chunk-54TK5BIS.mjs";
72
+ invert
73
+ } from "../chunk-OLX53VEF.mjs";
71
74
  import {
72
75
  omit
73
76
  } from "../chunk-WFZXCGEG.mjs";
@@ -83,13 +86,13 @@ import {
83
86
  import {
84
87
  clone
85
88
  } from "../chunk-VRUTBJYS.mjs";
89
+ import {
90
+ cloneDeep
91
+ } from "../chunk-5CPXZFCB.mjs";
86
92
  import {
87
93
  flattenObject
88
94
  } from "../chunk-XGQWTHW6.mjs";
89
95
  import "../chunk-MIGAC7F4.mjs";
90
- import {
91
- invert
92
- } from "../chunk-OLX53VEF.mjs";
93
96
  import "../chunk-FUS75PJ7.mjs";
94
97
  import {
95
98
  range
@@ -115,7 +118,29 @@ import {
115
118
  import {
116
119
  sum
117
120
  } from "../chunk-2SLTL4KL.mjs";
121
+ import "../chunk-ZA2XI3OV.mjs";
122
+ import {
123
+ throttle
124
+ } from "../chunk-QOJGMVVR.mjs";
125
+ import {
126
+ after
127
+ } from "../chunk-OGZMEWPR.mjs";
128
+ import {
129
+ debounce
130
+ } from "../chunk-3IP4JVLL.mjs";
131
+ import {
132
+ negate
133
+ } from "../chunk-BOOQBJN2.mjs";
134
+ import {
135
+ noop
136
+ } from "../chunk-LKXCOLNY.mjs";
137
+ import {
138
+ once
139
+ } from "../chunk-CMBC4MXG.mjs";
118
140
  import "../chunk-DDH7K4QM.mjs";
141
+ import {
142
+ zipObject
143
+ } from "../chunk-6GWEY5EL.mjs";
119
144
  import {
120
145
  zipWith
121
146
  } from "../chunk-4KYXHZ4R.mjs";
@@ -141,8 +166,8 @@ import {
141
166
  zip
142
167
  } from "../chunk-OLORW442.mjs";
143
168
  import {
144
- zipObject
145
- } from "../chunk-6GWEY5EL.mjs";
169
+ takeRightWhile
170
+ } from "../chunk-NTLX2MPV.mjs";
146
171
  import {
147
172
  takeWhile
148
173
  } from "../chunk-2IXFGSUA.mjs";
@@ -158,6 +183,9 @@ import {
158
183
  import {
159
184
  unionWith
160
185
  } from "../chunk-2ZCITDMK.mjs";
186
+ import {
187
+ uniqWith
188
+ } from "../chunk-237HGSZS.mjs";
161
189
  import {
162
190
  uniq
163
191
  } from "../chunk-DVK2N4KC.mjs";
@@ -165,8 +193,8 @@ import {
165
193
  uniqBy
166
194
  } from "../chunk-B4COTK4K.mjs";
167
195
  import {
168
- uniqWith
169
- } from "../chunk-237HGSZS.mjs";
196
+ orderBy
197
+ } from "../chunk-7B7W36UP.mjs";
170
198
  import {
171
199
  partition
172
200
  } from "../chunk-DN3NOZ3H.mjs";
@@ -195,8 +223,8 @@ import {
195
223
  takeRight
196
224
  } from "../chunk-N3QYJX4T.mjs";
197
225
  import {
198
- takeRightWhile
199
- } from "../chunk-NTLX2MPV.mjs";
226
+ initial
227
+ } from "../chunk-XPSOKBRZ.mjs";
200
228
  import {
201
229
  intersection
202
230
  } from "../chunk-FVVSE2F2.mjs";
@@ -218,9 +246,7 @@ import {
218
246
  import {
219
247
  minBy
220
248
  } from "../chunk-IJD7FE2Z.mjs";
221
- import {
222
- orderBy
223
- } from "../chunk-7B7W36UP.mjs";
249
+ import "../chunk-YFN6KOC4.mjs";
224
250
  import {
225
251
  flatMap
226
252
  } from "../chunk-UY76KTPE.mjs";
@@ -240,8 +266,8 @@ import {
240
266
  head
241
267
  } from "../chunk-HM2JT2RX.mjs";
242
268
  import {
243
- initial
244
- } from "../chunk-XPSOKBRZ.mjs";
269
+ countBy
270
+ } from "../chunk-CRSKT4WW.mjs";
245
271
  import "../chunk-JPUKH67K.mjs";
246
272
  import {
247
273
  differenceBy
@@ -261,27 +287,6 @@ import {
261
287
  import {
262
288
  dropWhile
263
289
  } from "../chunk-LJ2C6MVP.mjs";
264
- import "../chunk-YFN6KOC4.mjs";
265
- import "../chunk-ZA2XI3OV.mjs";
266
- import {
267
- negate
268
- } from "../chunk-BOOQBJN2.mjs";
269
- import {
270
- noop
271
- } from "../chunk-LKXCOLNY.mjs";
272
- import {
273
- once
274
- } from "../chunk-CMBC4MXG.mjs";
275
- import {
276
- throttle
277
- } from "../chunk-QOJGMVVR.mjs";
278
- import "../chunk-E6C5EZQA.mjs";
279
- import {
280
- compact
281
- } from "../chunk-DTJJIMKJ.mjs";
282
- import {
283
- countBy
284
- } from "../chunk-CRSKT4WW.mjs";
285
290
  import "../chunk-F47GLYUU.mjs";
286
291
  import {
287
292
  AbortError
@@ -289,12 +294,10 @@ import {
289
294
  import {
290
295
  TimeoutError
291
296
  } from "../chunk-KIOYQRMQ.mjs";
297
+ import "../chunk-E6C5EZQA.mjs";
292
298
  import {
293
- after
294
- } from "../chunk-OGZMEWPR.mjs";
295
- import {
296
- debounce
297
- } from "../chunk-3IP4JVLL.mjs";
299
+ compact
300
+ } from "../chunk-DTJJIMKJ.mjs";
298
301
  import "../chunk-24FKGR6U.mjs";
299
302
  export {
300
303
  AbortError,
@@ -305,6 +308,7 @@ export {
305
308
  chunk,
306
309
  clamp,
307
310
  clone,
311
+ cloneDeep,
308
312
  compact,
309
313
  concat,
310
314
  countBy,
@@ -1,13 +1,4 @@
1
1
  import "../chunk-ZA2XI3OV.mjs";
2
- import {
3
- negate
4
- } from "../chunk-BOOQBJN2.mjs";
5
- import {
6
- noop
7
- } from "../chunk-LKXCOLNY.mjs";
8
- import {
9
- once
10
- } from "../chunk-CMBC4MXG.mjs";
11
2
  import {
12
3
  throttle
13
4
  } from "../chunk-QOJGMVVR.mjs";
@@ -17,6 +8,15 @@ import {
17
8
  import {
18
9
  debounce
19
10
  } from "../chunk-3IP4JVLL.mjs";
11
+ import {
12
+ negate
13
+ } from "../chunk-BOOQBJN2.mjs";
14
+ import {
15
+ noop
16
+ } from "../chunk-LKXCOLNY.mjs";
17
+ import {
18
+ once
19
+ } from "../chunk-CMBC4MXG.mjs";
20
20
  import "../chunk-24FKGR6U.mjs";
21
21
  export {
22
22
  after,
package/dist/index.d.mts CHANGED
@@ -73,6 +73,7 @@ export { pick } from './object/pick.mjs';
73
73
  export { pickBy } from './object/pickBy.mjs';
74
74
  export { invert } from './object/invert.mjs';
75
75
  export { clone } from './object/clone.mjs';
76
+ export { cloneDeep } from './object/cloneDeep.mjs';
76
77
  export { flattenObject } from './object/flattenObject.mjs';
77
78
  export { isEqual } from './predicate/isEqual.mjs';
78
79
  export { isNil } from './predicate/isNil.mjs';
package/dist/index.d.ts CHANGED
@@ -73,6 +73,7 @@ export { pick } from './object/pick.js';
73
73
  export { pickBy } from './object/pickBy.js';
74
74
  export { invert } from './object/invert.js';
75
75
  export { clone } from './object/clone.js';
76
+ export { cloneDeep } from './object/cloneDeep.js';
76
77
  export { flattenObject } from './object/flattenObject.js';
77
78
  export { isEqual } from './predicate/isEqual.js';
78
79
  export { isNil } from './predicate/isNil.js';
package/dist/index.js CHANGED
@@ -62,6 +62,7 @@ __export(src_exports, {
62
62
  chunk: () => chunk,
63
63
  clamp: () => clamp,
64
64
  clone: () => clone,
65
+ cloneDeep: () => cloneDeep,
65
66
  compact: () => compact,
66
67
  countBy: () => countBy,
67
68
  debounce: () => debounce,
@@ -939,6 +940,95 @@ function isPrimitive(value) {
939
940
  return value == null || typeof value !== "object" && typeof value !== "function";
940
941
  }
941
942
 
943
+ // src/object/cloneDeep.ts
944
+ function cloneDeep(obj) {
945
+ if (isPrimitive2(obj)) {
946
+ return obj;
947
+ }
948
+ if (Array.isArray(obj)) {
949
+ return obj.map((item) => cloneDeep(item));
950
+ }
951
+ if (obj instanceof Date) {
952
+ return new Date(obj.getTime());
953
+ }
954
+ if (obj instanceof RegExp) {
955
+ return new RegExp(obj.source, obj.flags);
956
+ }
957
+ if (obj instanceof Map) {
958
+ const result = /* @__PURE__ */ new Map();
959
+ for (const [key, value] of obj.entries()) {
960
+ result.set(key, cloneDeep(value));
961
+ }
962
+ return result;
963
+ }
964
+ if (obj instanceof Set) {
965
+ const result = /* @__PURE__ */ new Set();
966
+ for (const value of obj.values()) {
967
+ result.add(cloneDeep(value));
968
+ }
969
+ return result;
970
+ }
971
+ if (isTypedArray(obj)) {
972
+ const result = new (Object.getPrototypeOf(obj)).constructor(obj.length);
973
+ for (let i = 0; i < obj.length; i++) {
974
+ result[i] = cloneDeep(obj[i]);
975
+ }
976
+ return result;
977
+ }
978
+ if (obj instanceof ArrayBuffer || obj instanceof SharedArrayBuffer) {
979
+ return obj.slice(0);
980
+ }
981
+ if (obj instanceof DataView) {
982
+ const result = new DataView(obj.buffer.slice(0));
983
+ cloneDeepHelper(obj, result);
984
+ return result;
985
+ }
986
+ if (typeof File !== "undefined" && obj instanceof File) {
987
+ const result = new File([obj], obj.name, { type: obj.type });
988
+ cloneDeepHelper(obj, result);
989
+ return result;
990
+ }
991
+ if (obj instanceof Blob) {
992
+ const result = new Blob([obj], { type: obj.type });
993
+ cloneDeepHelper(obj, result);
994
+ return result;
995
+ }
996
+ if (obj instanceof Error) {
997
+ const result = new obj.constructor();
998
+ result.message = obj.message;
999
+ result.name = obj.name;
1000
+ result.stack = obj.stack;
1001
+ result.cause = obj.cause;
1002
+ cloneDeepHelper(obj, result);
1003
+ return result;
1004
+ }
1005
+ if (typeof obj === "object" && obj !== null) {
1006
+ const result = {};
1007
+ cloneDeepHelper(obj, result);
1008
+ return result;
1009
+ }
1010
+ if (typeof obj === "function") {
1011
+ return void 0;
1012
+ }
1013
+ return obj;
1014
+ }
1015
+ function isPrimitive2(value) {
1016
+ return value == null || typeof value !== "object" && typeof value !== "function";
1017
+ }
1018
+ function cloneDeepHelper(obj, clonedObj) {
1019
+ for (const key in obj) {
1020
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1021
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
1022
+ if (((descriptor == null ? void 0 : descriptor.writable) || (descriptor == null ? void 0 : descriptor.set)) && typeof (descriptor == null ? void 0 : descriptor.value) !== "function") {
1023
+ clonedObj[key] = cloneDeep(obj[key]);
1024
+ }
1025
+ }
1026
+ }
1027
+ }
1028
+ function isTypedArray(obj) {
1029
+ return obj instanceof Uint8Array || obj instanceof Uint8ClampedArray || obj instanceof Uint16Array || obj instanceof Uint32Array || obj instanceof BigUint64Array || obj instanceof Int8Array || obj instanceof Int16Array || obj instanceof Int32Array || obj instanceof BigInt64Array || obj instanceof Float32Array || obj instanceof Float64Array;
1030
+ }
1031
+
942
1032
  // src/predicate/isPlainObject.ts
943
1033
  function isPlainObject(object) {
944
1034
  if (typeof object !== "object") {
@@ -1153,6 +1243,7 @@ function startCase(str) {
1153
1243
  chunk,
1154
1244
  clamp,
1155
1245
  clone,
1246
+ cloneDeep,
1156
1247
  compact,
1157
1248
  countBy,
1158
1249
  debounce,