es-toolkit 1.13.1-dev.316 → 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
@@ -1,4 +1,7 @@
1
1
  import "../chunk-DDH7K4QM.mjs";
2
+ import {
3
+ zipObject
4
+ } from "../chunk-6GWEY5EL.mjs";
2
5
  import {
3
6
  zipWith
4
7
  } from "../chunk-4KYXHZ4R.mjs";
@@ -24,8 +27,8 @@ import {
24
27
  zip
25
28
  } from "../chunk-OLORW442.mjs";
26
29
  import {
27
- zipObject
28
- } from "../chunk-6GWEY5EL.mjs";
30
+ takeRightWhile
31
+ } from "../chunk-NTLX2MPV.mjs";
29
32
  import {
30
33
  takeWhile
31
34
  } from "../chunk-2IXFGSUA.mjs";
@@ -41,6 +44,9 @@ import {
41
44
  import {
42
45
  unionWith
43
46
  } from "../chunk-2ZCITDMK.mjs";
47
+ import {
48
+ uniqWith
49
+ } from "../chunk-237HGSZS.mjs";
44
50
  import {
45
51
  uniq
46
52
  } from "../chunk-DVK2N4KC.mjs";
@@ -48,8 +54,8 @@ import {
48
54
  uniqBy
49
55
  } from "../chunk-B4COTK4K.mjs";
50
56
  import {
51
- uniqWith
52
- } from "../chunk-237HGSZS.mjs";
57
+ orderBy
58
+ } from "../chunk-7B7W36UP.mjs";
53
59
  import {
54
60
  partition
55
61
  } from "../chunk-DN3NOZ3H.mjs";
@@ -74,8 +80,8 @@ import {
74
80
  takeRight
75
81
  } from "../chunk-N3QYJX4T.mjs";
76
82
  import {
77
- takeRightWhile
78
- } from "../chunk-NTLX2MPV.mjs";
83
+ initial
84
+ } from "../chunk-XPSOKBRZ.mjs";
79
85
  import {
80
86
  intersection
81
87
  } from "../chunk-FVVSE2F2.mjs";
@@ -98,8 +104,8 @@ import {
98
104
  minBy
99
105
  } from "../chunk-IJD7FE2Z.mjs";
100
106
  import {
101
- orderBy
102
- } from "../chunk-7B7W36UP.mjs";
107
+ fill
108
+ } from "../chunk-YFN6KOC4.mjs";
103
109
  import {
104
110
  flatMap
105
111
  } from "../chunk-UY76KTPE.mjs";
@@ -119,8 +125,8 @@ import {
119
125
  head
120
126
  } from "../chunk-HM2JT2RX.mjs";
121
127
  import {
122
- initial
123
- } from "../chunk-XPSOKBRZ.mjs";
128
+ countBy
129
+ } from "../chunk-CRSKT4WW.mjs";
124
130
  import {
125
131
  difference
126
132
  } from "../chunk-JPUKH67K.mjs";
@@ -142,18 +148,12 @@ import {
142
148
  import {
143
149
  dropWhile
144
150
  } from "../chunk-LJ2C6MVP.mjs";
145
- import {
146
- fill
147
- } from "../chunk-YFN6KOC4.mjs";
148
151
  import {
149
152
  chunk
150
153
  } from "../chunk-E6C5EZQA.mjs";
151
154
  import {
152
155
  compact
153
156
  } from "../chunk-DTJJIMKJ.mjs";
154
- import {
155
- countBy
156
- } from "../chunk-CRSKT4WW.mjs";
157
157
  import "../chunk-24FKGR6U.mjs";
158
158
  export {
159
159
  chunk,
package/dist/browser.js CHANGED
@@ -51,6 +51,7 @@ __export(compat_exports, {
51
51
  chunk: () => chunk2,
52
52
  clamp: () => clamp,
53
53
  clone: () => clone,
54
+ cloneDeep: () => cloneDeep,
54
55
  compact: () => compact,
55
56
  concat: () => concat,
56
57
  countBy: () => countBy,
@@ -937,6 +938,95 @@ function isPrimitive(value) {
937
938
  return value == null || typeof value !== "object" && typeof value !== "function";
938
939
  }
939
940
 
941
+ // src/object/cloneDeep.ts
942
+ function cloneDeep(obj) {
943
+ if (isPrimitive2(obj)) {
944
+ return obj;
945
+ }
946
+ if (Array.isArray(obj)) {
947
+ return obj.map((item) => cloneDeep(item));
948
+ }
949
+ if (obj instanceof Date) {
950
+ return new Date(obj.getTime());
951
+ }
952
+ if (obj instanceof RegExp) {
953
+ return new RegExp(obj.source, obj.flags);
954
+ }
955
+ if (obj instanceof Map) {
956
+ const result = /* @__PURE__ */ new Map();
957
+ for (const [key, value] of obj.entries()) {
958
+ result.set(key, cloneDeep(value));
959
+ }
960
+ return result;
961
+ }
962
+ if (obj instanceof Set) {
963
+ const result = /* @__PURE__ */ new Set();
964
+ for (const value of obj.values()) {
965
+ result.add(cloneDeep(value));
966
+ }
967
+ return result;
968
+ }
969
+ if (isTypedArray(obj)) {
970
+ const result = new (Object.getPrototypeOf(obj)).constructor(obj.length);
971
+ for (let i = 0; i < obj.length; i++) {
972
+ result[i] = cloneDeep(obj[i]);
973
+ }
974
+ return result;
975
+ }
976
+ if (obj instanceof ArrayBuffer || obj instanceof SharedArrayBuffer) {
977
+ return obj.slice(0);
978
+ }
979
+ if (obj instanceof DataView) {
980
+ const result = new DataView(obj.buffer.slice(0));
981
+ cloneDeepHelper(obj, result);
982
+ return result;
983
+ }
984
+ if (typeof File !== "undefined" && obj instanceof File) {
985
+ const result = new File([obj], obj.name, { type: obj.type });
986
+ cloneDeepHelper(obj, result);
987
+ return result;
988
+ }
989
+ if (obj instanceof Blob) {
990
+ const result = new Blob([obj], { type: obj.type });
991
+ cloneDeepHelper(obj, result);
992
+ return result;
993
+ }
994
+ if (obj instanceof Error) {
995
+ const result = new obj.constructor();
996
+ result.message = obj.message;
997
+ result.name = obj.name;
998
+ result.stack = obj.stack;
999
+ result.cause = obj.cause;
1000
+ cloneDeepHelper(obj, result);
1001
+ return result;
1002
+ }
1003
+ if (typeof obj === "object" && obj !== null) {
1004
+ const result = {};
1005
+ cloneDeepHelper(obj, result);
1006
+ return result;
1007
+ }
1008
+ if (typeof obj === "function") {
1009
+ return void 0;
1010
+ }
1011
+ return obj;
1012
+ }
1013
+ function isPrimitive2(value) {
1014
+ return value == null || typeof value !== "object" && typeof value !== "function";
1015
+ }
1016
+ function cloneDeepHelper(obj, clonedObj) {
1017
+ for (const key in obj) {
1018
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1019
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
1020
+ if (((descriptor == null ? void 0 : descriptor.writable) || (descriptor == null ? void 0 : descriptor.set)) && typeof (descriptor == null ? void 0 : descriptor.value) !== "function") {
1021
+ clonedObj[key] = cloneDeep(obj[key]);
1022
+ }
1023
+ }
1024
+ }
1025
+ }
1026
+ function isTypedArray(obj) {
1027
+ 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;
1028
+ }
1029
+
940
1030
  // src/predicate/isPlainObject.ts
941
1031
  function isPlainObject(object) {
942
1032
  if (typeof object !== "object") {