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

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 (58) hide show
  1. package/dist/array/index.mjs +49 -49
  2. package/dist/browser.js +101 -0
  3. package/dist/browser.js.map +1 -1
  4. package/dist/browser.mjs +45 -43
  5. package/dist/browser.mjs.map +1 -1
  6. package/dist/chunk-5CPXZFCB.mjs +93 -0
  7. package/dist/chunk-5CPXZFCB.mjs.map +1 -0
  8. package/dist/chunk-STL6TD3L.mjs +1 -0
  9. package/dist/chunk-SXFMQQ6F.mjs +9 -0
  10. package/dist/chunk-SXFMQQ6F.mjs.map +1 -0
  11. package/dist/{chunk-HKO7DEJK.mjs → chunk-YNJH6GEG.mjs} +98 -84
  12. package/dist/chunk-YNJH6GEG.mjs.map +1 -0
  13. package/dist/chunk-YXAOYIRV.mjs +1 -0
  14. package/dist/compat/index.d.mts +20 -1
  15. package/dist/compat/index.d.ts +20 -1
  16. package/dist/compat/index.js +103 -0
  17. package/dist/compat/index.js.map +1 -1
  18. package/dist/compat/index.mjs +98 -91
  19. package/dist/error/index.mjs +3 -3
  20. package/dist/function/index.mjs +9 -9
  21. package/dist/index.d.mts +2 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +98 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +98 -90
  26. package/dist/object/cloneDeep.d.mts +64 -0
  27. package/dist/object/cloneDeep.d.ts +64 -0
  28. package/dist/object/cloneDeep.js +117 -0
  29. package/dist/object/cloneDeep.js.map +1 -0
  30. package/dist/object/cloneDeep.mjs +8 -0
  31. package/dist/object/cloneDeep.mjs.map +1 -0
  32. package/dist/object/index.d.mts +1 -0
  33. package/dist/object/index.d.ts +1 -0
  34. package/dist/object/index.js +91 -0
  35. package/dist/object/index.js.map +1 -1
  36. package/dist/object/index.mjs +8 -4
  37. package/dist/predicate/index.d.mts +1 -0
  38. package/dist/predicate/index.d.ts +1 -0
  39. package/dist/predicate/index.js +7 -0
  40. package/dist/predicate/index.js.map +1 -1
  41. package/dist/predicate/index.mjs +8 -4
  42. package/dist/predicate/isTypedArray.d.mts +19 -0
  43. package/dist/predicate/isTypedArray.d.ts +19 -0
  44. package/dist/predicate/isTypedArray.js +33 -0
  45. package/dist/predicate/isTypedArray.js.map +1 -0
  46. package/dist/predicate/isTypedArray.mjs +8 -0
  47. package/dist/predicate/isTypedArray.mjs.map +1 -0
  48. package/dist/promise/index.mjs +1 -1
  49. package/dist/promise/timeout.mjs +1 -1
  50. package/dist/promise/withTimeout.mjs +1 -1
  51. package/dist/string/index.mjs +6 -6
  52. package/package.json +1 -1
  53. package/umd/browser.global.js +1 -1
  54. package/dist/chunk-54TK5BIS.mjs +0 -1
  55. package/dist/chunk-HKO7DEJK.mjs.map +0 -1
  56. package/dist/chunk-U4JWMVQK.mjs +0 -1
  57. /package/dist/{chunk-54TK5BIS.mjs.map → chunk-STL6TD3L.mjs.map} +0 -0
  58. /package/dist/{chunk-U4JWMVQK.mjs.map → chunk-YXAOYIRV.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,5 +1,19 @@
1
1
  import "./chunk-NKLIE2OI.mjs";
2
+ import "./chunk-4OIZM4HS.mjs";
3
+ import {
4
+ withTimeout
5
+ } from "./chunk-IIDZ3KAJ.mjs";
6
+ import "./chunk-CVVZHOJX.mjs";
7
+ import {
8
+ delay
9
+ } from "./chunk-O64NE2P4.mjs";
2
10
  import "./chunk-XT74R35S.mjs";
11
+ import {
12
+ lowerCase
13
+ } from "./chunk-5IKVJGHO.mjs";
14
+ import {
15
+ snakeCase
16
+ } from "./chunk-F3WCQQET.mjs";
3
17
  import {
4
18
  startCase
5
19
  } from "./chunk-QXTNZR7B.mjs";
@@ -12,22 +26,11 @@ import {
12
26
  import {
13
27
  kebabCase
14
28
  } from "./chunk-EYYZQFOP.mjs";
15
- import {
16
- lowerCase
17
- } from "./chunk-5IKVJGHO.mjs";
18
- import {
19
- snakeCase
20
- } from "./chunk-F3WCQQET.mjs";
21
29
  import "./chunk-WVQ7YVRK.mjs";
22
- import "./chunk-4OIZM4HS.mjs";
30
+ import "./chunk-STL6TD3L.mjs";
23
31
  import {
24
- withTimeout
25
- } from "./chunk-IIDZ3KAJ.mjs";
26
- import "./chunk-CVVZHOJX.mjs";
27
- import {
28
- delay
29
- } from "./chunk-O64NE2P4.mjs";
30
- import "./chunk-U4JWMVQK.mjs";
32
+ isFunction
33
+ } from "./chunk-74CREQXW.mjs";
31
34
  import {
32
35
  isNil
33
36
  } from "./chunk-WMM7TZLG.mjs";
@@ -37,6 +40,9 @@ import {
37
40
  import {
38
41
  isNull
39
42
  } from "./chunk-AIRSKN47.mjs";
43
+ import {
44
+ isTypedArray
45
+ } from "./chunk-SXFMQQ6F.mjs";
40
46
  import {
41
47
  isUndefined
42
48
  } from "./chunk-VH2PV426.mjs";
@@ -49,10 +55,10 @@ import {
49
55
  import {
50
56
  isEqual
51
57
  } from "./chunk-JYSV56US.mjs";
58
+ import "./chunk-YXAOYIRV.mjs";
52
59
  import {
53
- isFunction
54
- } from "./chunk-74CREQXW.mjs";
55
- import "./chunk-54TK5BIS.mjs";
60
+ invert
61
+ } from "./chunk-OLX53VEF.mjs";
56
62
  import {
57
63
  omit
58
64
  } from "./chunk-WFZXCGEG.mjs";
@@ -68,15 +74,15 @@ import {
68
74
  import {
69
75
  clone
70
76
  } from "./chunk-VRUTBJYS.mjs";
77
+ import {
78
+ cloneDeep
79
+ } from "./chunk-5CPXZFCB.mjs";
71
80
  import {
72
81
  flattenObject
73
82
  } from "./chunk-XGQWTHW6.mjs";
74
83
  import {
75
84
  isPlainObject
76
85
  } from "./chunk-MIGAC7F4.mjs";
77
- import {
78
- invert
79
- } from "./chunk-OLX53VEF.mjs";
80
86
  import "./chunk-FUS75PJ7.mjs";
81
87
  import {
82
88
  range
@@ -102,19 +108,33 @@ import {
102
108
  import {
103
109
  sum
104
110
  } from "./chunk-2SLTL4KL.mjs";
105
- import "./chunk-DDH7K4QM.mjs";
111
+ import "./chunk-F47GLYUU.mjs";
106
112
  import {
107
- zipWith
108
- } from "./chunk-4KYXHZ4R.mjs";
113
+ TimeoutError
114
+ } from "./chunk-KIOYQRMQ.mjs";
115
+ import "./chunk-ZA2XI3OV.mjs";
109
116
  import {
110
- unzip
111
- } from "./chunk-UYZKMBDO.mjs";
117
+ throttle
118
+ } from "./chunk-QOJGMVVR.mjs";
112
119
  import {
113
- unzipWith
114
- } from "./chunk-IFNXROZR.mjs";
120
+ after
121
+ } from "./chunk-OGZMEWPR.mjs";
115
122
  import {
116
- without
117
- } from "./chunk-PYEYV7BY.mjs";
123
+ debounce
124
+ } from "./chunk-3IP4JVLL.mjs";
125
+ import {
126
+ negate
127
+ } from "./chunk-BOOQBJN2.mjs";
128
+ import {
129
+ noop
130
+ } from "./chunk-LKXCOLNY.mjs";
131
+ import {
132
+ once
133
+ } from "./chunk-CMBC4MXG.mjs";
134
+ import {
135
+ AbortError
136
+ } from "./chunk-DXB7EZUQ.mjs";
137
+ import "./chunk-DDH7K4QM.mjs";
118
138
  import {
119
139
  xor
120
140
  } from "./chunk-L7FQX5MN.mjs";
@@ -131,23 +151,14 @@ import {
131
151
  zipObject
132
152
  } from "./chunk-6GWEY5EL.mjs";
133
153
  import {
134
- takeWhile
135
- } from "./chunk-2IXFGSUA.mjs";
136
- import {
137
- toFilled
138
- } from "./chunk-OP4OAKQJ.mjs";
139
- import {
140
- union
141
- } from "./chunk-R6QA7PLZ.mjs";
154
+ zipWith
155
+ } from "./chunk-4KYXHZ4R.mjs";
142
156
  import {
143
157
  unionBy
144
158
  } from "./chunk-NFS7RWWE.mjs";
145
159
  import {
146
160
  unionWith
147
161
  } from "./chunk-2ZCITDMK.mjs";
148
- import {
149
- uniq
150
- } from "./chunk-DVK2N4KC.mjs";
151
162
  import {
152
163
  uniqBy
153
164
  } from "./chunk-B4COTK4K.mjs";
@@ -155,20 +166,14 @@ import {
155
166
  uniqWith
156
167
  } from "./chunk-237HGSZS.mjs";
157
168
  import {
158
- partition
159
- } from "./chunk-DN3NOZ3H.mjs";
160
- import {
161
- sample
162
- } from "./chunk-2KNLZB7V.mjs";
163
- import {
164
- sampleSize
165
- } from "./chunk-EHSKB6DF.mjs";
169
+ unzip
170
+ } from "./chunk-UYZKMBDO.mjs";
166
171
  import {
167
- randomInt
168
- } from "./chunk-GIWAOOFY.mjs";
172
+ unzipWith
173
+ } from "./chunk-IFNXROZR.mjs";
169
174
  import {
170
- random
171
- } from "./chunk-SYWMYQYJ.mjs";
175
+ without
176
+ } from "./chunk-PYEYV7BY.mjs";
172
177
  import {
173
178
  shuffle
174
179
  } from "./chunk-G7UQ5PUR.mjs";
@@ -185,14 +190,17 @@ import {
185
190
  takeRightWhile
186
191
  } from "./chunk-NTLX2MPV.mjs";
187
192
  import {
188
- intersection
189
- } from "./chunk-FVVSE2F2.mjs";
193
+ takeWhile
194
+ } from "./chunk-2IXFGSUA.mjs";
190
195
  import {
191
- intersectionBy
192
- } from "./chunk-O6UXZR3U.mjs";
196
+ toFilled
197
+ } from "./chunk-OP4OAKQJ.mjs";
193
198
  import {
194
- intersectionWith
195
- } from "./chunk-XI7KRD2C.mjs";
199
+ union
200
+ } from "./chunk-R6QA7PLZ.mjs";
201
+ import {
202
+ uniq
203
+ } from "./chunk-DVK2N4KC.mjs";
196
204
  import {
197
205
  keyBy
198
206
  } from "./chunk-AJKZMN2V.mjs";
@@ -209,14 +217,20 @@ import {
209
217
  orderBy
210
218
  } from "./chunk-7B7W36UP.mjs";
211
219
  import {
212
- flatMap
213
- } from "./chunk-UY76KTPE.mjs";
220
+ partition
221
+ } from "./chunk-DN3NOZ3H.mjs";
214
222
  import {
215
- flattenDeep
216
- } from "./chunk-ML727RRJ.mjs";
223
+ sample
224
+ } from "./chunk-2KNLZB7V.mjs";
217
225
  import {
218
- flatten
219
- } from "./chunk-33MSBDC6.mjs";
226
+ sampleSize
227
+ } from "./chunk-EHSKB6DF.mjs";
228
+ import {
229
+ randomInt
230
+ } from "./chunk-GIWAOOFY.mjs";
231
+ import {
232
+ random
233
+ } from "./chunk-SYWMYQYJ.mjs";
220
234
  import {
221
235
  forEachRight
222
236
  } from "./chunk-IEA53J7P.mjs";
@@ -230,14 +244,14 @@ import {
230
244
  initial
231
245
  } from "./chunk-XPSOKBRZ.mjs";
232
246
  import {
233
- difference
234
- } from "./chunk-JPUKH67K.mjs";
247
+ intersection
248
+ } from "./chunk-FVVSE2F2.mjs";
235
249
  import {
236
- differenceBy
237
- } from "./chunk-LVWX5B43.mjs";
250
+ intersectionBy
251
+ } from "./chunk-O6UXZR3U.mjs";
238
252
  import {
239
- differenceWith
240
- } from "./chunk-6NVQAHXP.mjs";
253
+ intersectionWith
254
+ } from "./chunk-XI7KRD2C.mjs";
241
255
  import {
242
256
  drop
243
257
  } from "./chunk-3EZAFZG3.mjs";
@@ -253,19 +267,15 @@ import {
253
267
  import {
254
268
  fill
255
269
  } from "./chunk-YFN6KOC4.mjs";
256
- import "./chunk-ZA2XI3OV.mjs";
257
- import {
258
- negate
259
- } from "./chunk-BOOQBJN2.mjs";
260
270
  import {
261
- noop
262
- } from "./chunk-LKXCOLNY.mjs";
271
+ flatMap
272
+ } from "./chunk-UY76KTPE.mjs";
263
273
  import {
264
- once
265
- } from "./chunk-CMBC4MXG.mjs";
274
+ flattenDeep
275
+ } from "./chunk-ML727RRJ.mjs";
266
276
  import {
267
- throttle
268
- } from "./chunk-QOJGMVVR.mjs";
277
+ flatten
278
+ } from "./chunk-33MSBDC6.mjs";
269
279
  import {
270
280
  chunk
271
281
  } from "./chunk-E6C5EZQA.mjs";
@@ -275,19 +285,15 @@ import {
275
285
  import {
276
286
  countBy
277
287
  } from "./chunk-CRSKT4WW.mjs";
278
- import "./chunk-F47GLYUU.mjs";
279
288
  import {
280
- AbortError
281
- } from "./chunk-DXB7EZUQ.mjs";
282
- import {
283
- TimeoutError
284
- } from "./chunk-KIOYQRMQ.mjs";
289
+ difference
290
+ } from "./chunk-JPUKH67K.mjs";
285
291
  import {
286
- after
287
- } from "./chunk-OGZMEWPR.mjs";
292
+ differenceBy
293
+ } from "./chunk-LVWX5B43.mjs";
288
294
  import {
289
- debounce
290
- } from "./chunk-3IP4JVLL.mjs";
295
+ differenceWith
296
+ } from "./chunk-6NVQAHXP.mjs";
291
297
  import "./chunk-24FKGR6U.mjs";
292
298
  export {
293
299
  AbortError,
@@ -298,6 +304,7 @@ export {
298
304
  chunk,
299
305
  clamp,
300
306
  clone,
307
+ cloneDeep,
301
308
  compact,
302
309
  countBy,
303
310
  debounce,
@@ -331,6 +338,7 @@ export {
331
338
  isNotNil,
332
339
  isNull,
333
340
  isPlainObject,
341
+ isTypedArray,
334
342
  isUndefined,
335
343
  kebabCase,
336
344
  keyBy,
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Creates a deep clone of the given object.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to clone.
6
+ * @returns {T} - A deep clone of the given object.
7
+ *
8
+ * @example
9
+ * // Clone a primitive values
10
+ * const num = 29;
11
+ * const clonedNum = clone(num);
12
+ * console.log(clonedNum); // 29
13
+ * console.log(clonedNum === num) ; // true
14
+ *
15
+ * @example
16
+ * // Clone an array
17
+ * const arr = [1, 2, 3];
18
+ * const clonedArr = clone(arr);
19
+ * console.log(clonedArr); // [1, 2, 3]
20
+ * console.log(clonedArr === arr); // false
21
+ *
22
+ * @example
23
+ * // Clone an array with nested objects
24
+ * const arr = [1, { a: 1 }, [1, 2, 3]];
25
+ * const clonedArr = clone(arr);
26
+ * arr[1].a = 2;
27
+ * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28
+ * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
29
+ * console.log(clonedArr === arr); // false
30
+ *
31
+ * @example
32
+ * // Clone an object
33
+ * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
34
+ * const clonedObj = clone(obj);
35
+ * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
36
+ * console.log(clonedObj === obj); // false
37
+ *
38
+ * @example
39
+ * // Clone an object with nested objects
40
+ * const obj = { a: 1, b: { c: 1 } };
41
+ * const clonedObj = clone(obj);
42
+ * obj.b.c = 2;
43
+ * console.log(obj); // { a: 1, b: { c: 2 } }
44
+ * console.log(clonedObj); // { a: 1, b: { c: 1 } }
45
+ * console.log(clonedObj === obj); // false
46
+ */
47
+ declare function cloneDeep<T>(obj: T): Resolved<T>;
48
+ type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
49
+ type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
50
+ type ResolvedMain<T> = T extends [never] ? never : ValueOf<T> extends boolean | number | bigint | string ? ValueOf<T> : T extends (...args: any[]) => any ? never : T extends object ? ResolvedObject<T> : ValueOf<T>;
51
+ type ResolvedObject<T extends object> = T extends Array<infer U> ? IsTuple<T> extends true ? ResolvedTuple<T> : Array<ResolvedMain<U>> : T extends Set<infer U> ? Set<ResolvedMain<U>> : T extends Map<infer K, infer V> ? Map<ResolvedMain<K>, ResolvedMain<V>> : T extends WeakSet<any> | WeakMap<any, any> ? never : T extends Date | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array | ArrayBuffer | SharedArrayBuffer | DataView | Blob | File ? T : {
52
+ [P in keyof T]: ResolvedMain<T[P]>;
53
+ };
54
+ type ResolvedTuple<T extends readonly any[]> = T extends [] ? [] : T extends [infer F] ? [ResolvedMain<F>] : T extends [infer F, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>, ...ResolvedTuple<Rest>] : T extends [(infer F)?] ? [ResolvedMain<F>?] : T extends [(infer F)?, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>] : [];
55
+ type IsTuple<T extends readonly any[] | {
56
+ length: number;
57
+ }> = [T] extends [never] ? false : T extends readonly any[] ? number extends T['length'] ? false : true : false;
58
+ type ValueOf<Instance> = IsValueOf<Instance, boolean> extends true ? boolean : IsValueOf<Instance, number> extends true ? number : IsValueOf<Instance, string> extends true ? string : Instance;
59
+ type IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O ? O extends IValueOf<infer Primitive> ? Instance extends Primitive ? false : true : false : false;
60
+ interface IValueOf<T> {
61
+ valueOf(): T;
62
+ }
63
+
64
+ export { type Resolved, cloneDeep };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Creates a deep clone of the given object.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to clone.
6
+ * @returns {T} - A deep clone of the given object.
7
+ *
8
+ * @example
9
+ * // Clone a primitive values
10
+ * const num = 29;
11
+ * const clonedNum = clone(num);
12
+ * console.log(clonedNum); // 29
13
+ * console.log(clonedNum === num) ; // true
14
+ *
15
+ * @example
16
+ * // Clone an array
17
+ * const arr = [1, 2, 3];
18
+ * const clonedArr = clone(arr);
19
+ * console.log(clonedArr); // [1, 2, 3]
20
+ * console.log(clonedArr === arr); // false
21
+ *
22
+ * @example
23
+ * // Clone an array with nested objects
24
+ * const arr = [1, { a: 1 }, [1, 2, 3]];
25
+ * const clonedArr = clone(arr);
26
+ * arr[1].a = 2;
27
+ * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28
+ * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
29
+ * console.log(clonedArr === arr); // false
30
+ *
31
+ * @example
32
+ * // Clone an object
33
+ * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
34
+ * const clonedObj = clone(obj);
35
+ * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
36
+ * console.log(clonedObj === obj); // false
37
+ *
38
+ * @example
39
+ * // Clone an object with nested objects
40
+ * const obj = { a: 1, b: { c: 1 } };
41
+ * const clonedObj = clone(obj);
42
+ * obj.b.c = 2;
43
+ * console.log(obj); // { a: 1, b: { c: 2 } }
44
+ * console.log(clonedObj); // { a: 1, b: { c: 1 } }
45
+ * console.log(clonedObj === obj); // false
46
+ */
47
+ declare function cloneDeep<T>(obj: T): Resolved<T>;
48
+ type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
49
+ type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
50
+ type ResolvedMain<T> = T extends [never] ? never : ValueOf<T> extends boolean | number | bigint | string ? ValueOf<T> : T extends (...args: any[]) => any ? never : T extends object ? ResolvedObject<T> : ValueOf<T>;
51
+ type ResolvedObject<T extends object> = T extends Array<infer U> ? IsTuple<T> extends true ? ResolvedTuple<T> : Array<ResolvedMain<U>> : T extends Set<infer U> ? Set<ResolvedMain<U>> : T extends Map<infer K, infer V> ? Map<ResolvedMain<K>, ResolvedMain<V>> : T extends WeakSet<any> | WeakMap<any, any> ? never : T extends Date | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array | ArrayBuffer | SharedArrayBuffer | DataView | Blob | File ? T : {
52
+ [P in keyof T]: ResolvedMain<T[P]>;
53
+ };
54
+ type ResolvedTuple<T extends readonly any[]> = T extends [] ? [] : T extends [infer F] ? [ResolvedMain<F>] : T extends [infer F, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>, ...ResolvedTuple<Rest>] : T extends [(infer F)?] ? [ResolvedMain<F>?] : T extends [(infer F)?, ...infer Rest extends readonly any[]] ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>] : [];
55
+ type IsTuple<T extends readonly any[] | {
56
+ length: number;
57
+ }> = [T] extends [never] ? false : T extends readonly any[] ? number extends T['length'] ? false : true : false;
58
+ type ValueOf<Instance> = IsValueOf<Instance, boolean> extends true ? boolean : IsValueOf<Instance, number> extends true ? number : IsValueOf<Instance, string> extends true ? string : Instance;
59
+ type IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O ? O extends IValueOf<infer Primitive> ? Instance extends Primitive ? false : true : false : false;
60
+ interface IValueOf<T> {
61
+ valueOf(): T;
62
+ }
63
+
64
+ export { type Resolved, cloneDeep };
@@ -0,0 +1,117 @@
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/cloneDeep.ts
21
+ var cloneDeep_exports = {};
22
+ __export(cloneDeep_exports, {
23
+ cloneDeep: () => cloneDeep
24
+ });
25
+ module.exports = __toCommonJS(cloneDeep_exports);
26
+ function cloneDeep(obj) {
27
+ if (isPrimitive(obj)) {
28
+ return obj;
29
+ }
30
+ if (Array.isArray(obj)) {
31
+ return obj.map((item) => cloneDeep(item));
32
+ }
33
+ if (obj instanceof Date) {
34
+ return new Date(obj.getTime());
35
+ }
36
+ if (obj instanceof RegExp) {
37
+ return new RegExp(obj.source, obj.flags);
38
+ }
39
+ if (obj instanceof Map) {
40
+ const result = /* @__PURE__ */ new Map();
41
+ for (const [key, value] of obj.entries()) {
42
+ result.set(key, cloneDeep(value));
43
+ }
44
+ return result;
45
+ }
46
+ if (obj instanceof Set) {
47
+ const result = /* @__PURE__ */ new Set();
48
+ for (const value of obj.values()) {
49
+ result.add(cloneDeep(value));
50
+ }
51
+ return result;
52
+ }
53
+ if (isTypedArray(obj)) {
54
+ const result = new (Object.getPrototypeOf(obj)).constructor(obj.length);
55
+ for (let i = 0; i < obj.length; i++) {
56
+ result[i] = cloneDeep(obj[i]);
57
+ }
58
+ return result;
59
+ }
60
+ if (obj instanceof ArrayBuffer || obj instanceof SharedArrayBuffer) {
61
+ return obj.slice(0);
62
+ }
63
+ if (obj instanceof DataView) {
64
+ const result = new DataView(obj.buffer.slice(0));
65
+ cloneDeepHelper(obj, result);
66
+ return result;
67
+ }
68
+ if (typeof File !== "undefined" && obj instanceof File) {
69
+ const result = new File([obj], obj.name, { type: obj.type });
70
+ cloneDeepHelper(obj, result);
71
+ return result;
72
+ }
73
+ if (obj instanceof Blob) {
74
+ const result = new Blob([obj], { type: obj.type });
75
+ cloneDeepHelper(obj, result);
76
+ return result;
77
+ }
78
+ if (obj instanceof Error) {
79
+ const result = new obj.constructor();
80
+ result.message = obj.message;
81
+ result.name = obj.name;
82
+ result.stack = obj.stack;
83
+ result.cause = obj.cause;
84
+ cloneDeepHelper(obj, result);
85
+ return result;
86
+ }
87
+ if (typeof obj === "object" && obj !== null) {
88
+ const result = {};
89
+ cloneDeepHelper(obj, result);
90
+ return result;
91
+ }
92
+ if (typeof obj === "function") {
93
+ return void 0;
94
+ }
95
+ return obj;
96
+ }
97
+ function isPrimitive(value) {
98
+ return value == null || typeof value !== "object" && typeof value !== "function";
99
+ }
100
+ function cloneDeepHelper(obj, clonedObj) {
101
+ for (const key in obj) {
102
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
103
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
104
+ if (((descriptor == null ? void 0 : descriptor.writable) || (descriptor == null ? void 0 : descriptor.set)) && typeof (descriptor == null ? void 0 : descriptor.value) !== "function") {
105
+ clonedObj[key] = cloneDeep(obj[key]);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ function isTypedArray(obj) {
111
+ 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;
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ cloneDeep
116
+ });
117
+ //# sourceMappingURL=cloneDeep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/object/cloneDeep.ts"],"sourcesContent":["/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => cloneDeep(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeep(obj[i]);\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof ArrayBuffer || obj instanceof SharedArrayBuffer) {\n return obj.slice(0) as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0));\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new (): Error })();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'function') {\n return void 0 as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n\n// eslint-disable-next-line\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== 'function') {\n clonedObj[key] = cloneDeep(obj[key]);\n }\n }\n }\n}\n\nfunction isTypedArray(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n\nexport type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> =\n T extends Array<infer U>\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : Array<ResolvedMain<U>>\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [never]\n ? false\n : T extends readonly any[]\n ? number extends T['length']\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O\n ? O extends IValueOf<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface IValueOf<T> {\n valueOf(): T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,SAAS,UAAa,KAAqB;AAChD,MAAI,YAAY,GAAG,GAAG;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,IAAI,UAAQ,UAAU,IAAI,CAAC;AAAA,EACxC;AAEA,MAAI,eAAe,MAAM;AACvB,WAAO,IAAI,KAAK,IAAI,QAAQ,CAAC;AAAA,EAC/B;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK;AAAA,EACzC;AAEA,MAAI,eAAe,KAAK;AACtB,UAAM,SAAS,oBAAI,IAAI;AACvB,eAAW,CAAC,KAAK,KAAK,KAAK,IAAI,QAAQ,GAAG;AACxC,aAAO,IAAI,KAAK,UAAU,KAAK,CAAC;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,KAAK;AACtB,UAAM,SAAS,oBAAI,IAAI;AACvB,eAAW,SAAS,IAAI,OAAO,GAAG;AAChC,aAAO,IAAI,UAAU,KAAK,CAAC;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,GAAG,GAAG;AACrB,UAAM,SAAS,KAAK,OAAO,eAAe,GAAG,GAAE,YAAa,IAAI,MAAM;AACtE,aAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,aAAO,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,eAAe,eAAe,mBAAmB;AAClE,WAAO,IAAI,MAAM,CAAC;AAAA,EACpB;AAEA,MAAI,eAAe,UAAU;AAC3B,UAAM,SAAS,IAAI,SAAS,IAAI,OAAO,MAAM,CAAC,CAAC;AAC/C,oBAAgB,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,SAAS,eAAe,eAAe,MAAM;AACtD,UAAM,SAAS,IAAI,KAAK,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC;AAC3D,oBAAgB,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,MAAM;AACvB,UAAM,SAAS,IAAI,KAAK,CAAC,GAAG,GAAG,EAAE,MAAM,IAAI,KAAK,CAAC;AACjD,oBAAgB,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,OAAO;AACxB,UAAM,SAAS,IAAK,IAAI,YAAkC;AAC1D,WAAO,UAAU,IAAI;AACrB,WAAO,OAAO,IAAI;AAClB,WAAO,QAAQ,IAAI;AACnB,WAAO,QAAQ,IAAI;AACnB,oBAAgB,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,UAAM,SAAS,CAAC;AAChB,oBAAgB,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAGA,SAAS,YAAY,OAAoC;AACvD,SAAO,SAAS,QAAS,OAAO,UAAU,YAAY,OAAO,UAAU;AACzE;AAGA,SAAS,gBAAgB,KAAU,WAAsB;AACvD,aAAW,OAAO,KAAK;AACrB,QAAI,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG,GAAG;AAClD,YAAM,aAAa,OAAO,yBAAyB,KAAK,GAAG;AAC3D,YAAK,yCAAY,cAAY,yCAAY,SAAQ,QAAO,yCAAY,WAAU,YAAY;AACxF,kBAAU,GAAG,IAAI,UAAU,IAAI,GAAG,CAAC;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,aAEP,KAYe;AACf,SACE,eAAe,cACf,eAAe,qBACf,eAAe,eACf,eAAe,eACf,eAAe,kBACf,eAAe,aACf,eAAe,cACf,eAAe,cACf,eAAe,iBACf,eAAe,gBACf,eAAe;AAEnB;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ cloneDeep
3
+ } from "../chunk-5CPXZFCB.mjs";
4
+ import "../chunk-24FKGR6U.mjs";
5
+ export {
6
+ cloneDeep
7
+ };
8
+ //# sourceMappingURL=cloneDeep.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -4,4 +4,5 @@ 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 { cloneDeep } from './cloneDeep.mjs';
7
8
  export { flattenObject } from './flattenObject.mjs';
@@ -4,4 +4,5 @@ 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 { cloneDeep } from './cloneDeep.js';
7
8
  export { flattenObject } from './flattenObject.js';