@fangzhongya/utils 0.0.50 → 0.0.56
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.
- package/dist/basic/index.cjs +10 -9
- package/dist/basic/index.d.cts +2 -1
- package/dist/basic/index.d.ts +2 -1
- package/dist/basic/index.js +9 -8
- package/dist/basic/object/deepCopys.cjs +17 -0
- package/dist/basic/object/deepCopys.d.cts +31 -0
- package/dist/basic/object/deepCopys.d.ts +31 -0
- package/dist/basic/object/deepCopys.js +17 -0
- package/dist/basic/object/index.cjs +22 -8
- package/dist/basic/object/index.d.cts +1 -0
- package/dist/basic/object/index.d.ts +1 -0
- package/dist/basic/object/index.js +21 -7
- package/dist/basic/string/index.cjs +10 -10
- package/dist/basic/string/index.js +12 -12
- package/dist/{chunk-UCDL7HLX.cjs → chunk-3QR3J6AE.cjs} +20 -6
- package/dist/{chunk-Z4TJLQF2.js → chunk-BYQGX3ZV.js} +2 -2
- package/dist/{chunk-J2WRN55J.cjs → chunk-FL2HPQ66.cjs} +6 -6
- package/dist/chunk-SJ74DU4B.cjs +275 -0
- package/dist/{chunk-53EIYZSN.cjs → chunk-SUAM6STT.cjs} +4 -4
- package/dist/{chunk-XU7MQD33.js → chunk-SVK3J3CY.js} +20 -6
- package/dist/{chunk-7VGVDOZH.js → chunk-X44UO4CZ.js} +12 -12
- package/dist/chunk-YMKTU42G.js +275 -0
- package/dist/{index-BHI-3z9i.d.cts → index-Cz8fWd5l.d.cts} +8 -1
- package/dist/{index-C6fjPfzn.d.ts → index-J-xiEtN9.d.ts} +1 -1
- package/dist/{index-DYRjlOZp.d.cts → index-KftqgSWD.d.cts} +1 -1
- package/dist/{index-qKkaUBR7.d.ts → index-oW2flHUo.d.ts} +8 -1
- package/dist/index.cjs +19 -18
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +18 -17
- package/dist/judge/index.cjs +7 -7
- package/dist/judge/index.js +13 -13
- package/dist/judge/matchs.cjs +3 -3
- package/dist/judge/matchs.js +2 -2
- package/package.json +11 -6
- package/dist/{chunk-T2QKEABG.js → chunk-33X65PQS.js} +3 -3
- package/dist/{chunk-T22I7TJQ.cjs → chunk-3YUI42XN.cjs} +3 -3
- package/dist/{chunk-LY3XJLNL.js → chunk-5GWQIIRZ.js} +11 -11
- package/dist/{chunk-QC5UCHB5.cjs → chunk-QHMO7DUJ.cjs} +9 -9
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// packages/basic/object/deepCopys.ts
|
|
2
|
+
function deepCopys(obj, options = {}) {
|
|
3
|
+
const {
|
|
4
|
+
visited = /* @__PURE__ */ new WeakMap(),
|
|
5
|
+
maxDepth = 100,
|
|
6
|
+
handleProxy = "unwrap",
|
|
7
|
+
currentDepth = 0
|
|
8
|
+
} = options;
|
|
9
|
+
if (currentDepth >= maxDepth) {
|
|
10
|
+
console.warn("deepCopys: Maximum depth reached, returning reference");
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
if (typeof obj === "function") {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
if (visited.has(obj)) {
|
|
20
|
+
return visited.get(obj);
|
|
21
|
+
}
|
|
22
|
+
const isProxy = isProxyObject(obj);
|
|
23
|
+
if (isProxy) {
|
|
24
|
+
switch (handleProxy) {
|
|
25
|
+
case "unwrap":
|
|
26
|
+
const rawValue = getProxyTarget(obj);
|
|
27
|
+
if (rawValue !== obj) {
|
|
28
|
+
return deepCopys(rawValue, {
|
|
29
|
+
visited,
|
|
30
|
+
maxDepth,
|
|
31
|
+
handleProxy,
|
|
32
|
+
currentDepth: currentDepth + 1
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
case "clone":
|
|
37
|
+
const target = getProxyTarget(obj);
|
|
38
|
+
if (target !== obj) {
|
|
39
|
+
const result = deepCopys(target, {
|
|
40
|
+
visited,
|
|
41
|
+
maxDepth,
|
|
42
|
+
handleProxy,
|
|
43
|
+
currentDepth: currentDepth + 1
|
|
44
|
+
});
|
|
45
|
+
visited.set(obj, result);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case "keep":
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (obj instanceof Date) {
|
|
54
|
+
const copy = new Date(obj.getTime());
|
|
55
|
+
visited.set(obj, copy);
|
|
56
|
+
return copy;
|
|
57
|
+
}
|
|
58
|
+
if (obj instanceof RegExp) {
|
|
59
|
+
const copy = new RegExp(obj.source, obj.flags);
|
|
60
|
+
visited.set(obj, copy);
|
|
61
|
+
return copy;
|
|
62
|
+
}
|
|
63
|
+
if (obj instanceof Map) {
|
|
64
|
+
const copy = /* @__PURE__ */ new Map();
|
|
65
|
+
visited.set(obj, copy);
|
|
66
|
+
obj.forEach((value, key) => {
|
|
67
|
+
copy.set(
|
|
68
|
+
deepCopys(key, {
|
|
69
|
+
visited,
|
|
70
|
+
maxDepth,
|
|
71
|
+
handleProxy,
|
|
72
|
+
currentDepth: currentDepth + 1
|
|
73
|
+
}),
|
|
74
|
+
deepCopys(value, {
|
|
75
|
+
visited,
|
|
76
|
+
maxDepth,
|
|
77
|
+
handleProxy,
|
|
78
|
+
currentDepth: currentDepth + 1
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
return copy;
|
|
83
|
+
}
|
|
84
|
+
if (obj instanceof Set) {
|
|
85
|
+
const copy = /* @__PURE__ */ new Set();
|
|
86
|
+
visited.set(obj, copy);
|
|
87
|
+
obj.forEach((value) => {
|
|
88
|
+
copy.add(
|
|
89
|
+
deepCopys(value, {
|
|
90
|
+
visited,
|
|
91
|
+
maxDepth,
|
|
92
|
+
handleProxy,
|
|
93
|
+
currentDepth: currentDepth + 1
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
return copy;
|
|
98
|
+
}
|
|
99
|
+
if (obj instanceof ArrayBuffer) {
|
|
100
|
+
const copy = obj.slice(0);
|
|
101
|
+
visited.set(obj, copy);
|
|
102
|
+
return copy;
|
|
103
|
+
}
|
|
104
|
+
if (ArrayBuffer.isView(obj)) {
|
|
105
|
+
const copy = obj.slice();
|
|
106
|
+
visited.set(obj, copy);
|
|
107
|
+
return copy;
|
|
108
|
+
}
|
|
109
|
+
if (isPromise(obj)) {
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
const objClone = Array.isArray(obj) ? [] : {};
|
|
113
|
+
visited.set(obj, objClone);
|
|
114
|
+
const keys = getAllPropertyKeys(obj);
|
|
115
|
+
for (const key of keys) {
|
|
116
|
+
try {
|
|
117
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
118
|
+
obj,
|
|
119
|
+
key
|
|
120
|
+
);
|
|
121
|
+
if (descriptor && descriptor.get) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const value = obj[key];
|
|
125
|
+
objClone[key] = deepCopys(value, {
|
|
126
|
+
visited,
|
|
127
|
+
maxDepth,
|
|
128
|
+
handleProxy,
|
|
129
|
+
currentDepth: currentDepth + 1
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return objClone;
|
|
136
|
+
}
|
|
137
|
+
function isProxyObject(obj) {
|
|
138
|
+
if (!obj || typeof obj !== "object") return false;
|
|
139
|
+
try {
|
|
140
|
+
if (obj && obj.__v_isReactive || obj.__v_isReadonly) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
} catch (e2) {
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const str = Object.prototype.toString.call(obj);
|
|
147
|
+
if (str === "[object Proxy]") {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
} catch (e3) {
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
function getProxyTarget(obj) {
|
|
155
|
+
if (!obj || typeof obj !== "object") return obj;
|
|
156
|
+
try {
|
|
157
|
+
const raw = obj.__v_raw;
|
|
158
|
+
if (raw !== void 0) {
|
|
159
|
+
return raw;
|
|
160
|
+
}
|
|
161
|
+
} catch (e4) {
|
|
162
|
+
}
|
|
163
|
+
return obj;
|
|
164
|
+
}
|
|
165
|
+
function isPromise(obj) {
|
|
166
|
+
return obj && typeof obj === "object" && typeof obj.then === "function";
|
|
167
|
+
}
|
|
168
|
+
function getAllPropertyKeys(obj) {
|
|
169
|
+
const keys = [];
|
|
170
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
171
|
+
keys.push(...ownKeys);
|
|
172
|
+
return keys;
|
|
173
|
+
}
|
|
174
|
+
function safeDeepCopy(obj) {
|
|
175
|
+
try {
|
|
176
|
+
const rawObj = getRawReactiveValue(obj);
|
|
177
|
+
if (rawObj !== obj) {
|
|
178
|
+
return deepCopys(rawObj, {
|
|
179
|
+
handleProxy: "unwrap",
|
|
180
|
+
maxDepth: 50
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
} catch (error) {
|
|
184
|
+
}
|
|
185
|
+
return deepCopys(obj, {
|
|
186
|
+
handleProxy: "unwrap",
|
|
187
|
+
maxDepth: 50
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function getRawReactiveValue(obj) {
|
|
191
|
+
if (!obj || typeof obj !== "object") return obj;
|
|
192
|
+
try {
|
|
193
|
+
const raw = obj.__v_raw;
|
|
194
|
+
if (raw !== void 0) {
|
|
195
|
+
return raw;
|
|
196
|
+
}
|
|
197
|
+
} catch (e5) {
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
if (obj.__ob__) {
|
|
201
|
+
const plainObj = { ...obj };
|
|
202
|
+
delete plainObj.__ob__;
|
|
203
|
+
return plainObj;
|
|
204
|
+
}
|
|
205
|
+
} catch (e6) {
|
|
206
|
+
}
|
|
207
|
+
return obj;
|
|
208
|
+
}
|
|
209
|
+
function fastDeepCopy(obj) {
|
|
210
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
211
|
+
return obj;
|
|
212
|
+
}
|
|
213
|
+
if (obj instanceof Date) {
|
|
214
|
+
return new Date(obj.getTime());
|
|
215
|
+
}
|
|
216
|
+
if (obj instanceof RegExp) {
|
|
217
|
+
return new RegExp(obj.source, obj.flags);
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
return JSON.parse(JSON.stringify(obj));
|
|
221
|
+
} catch (e) {
|
|
222
|
+
console.warn("fastDeepCopy failed, falling back to deepCopys", e);
|
|
223
|
+
return deepCopys(obj, {
|
|
224
|
+
handleProxy: "unwrap",
|
|
225
|
+
maxDepth: 100
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function structuredCloneCopy(obj) {
|
|
230
|
+
if (typeof structuredClone === "function") {
|
|
231
|
+
try {
|
|
232
|
+
return structuredClone(obj);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.warn(
|
|
235
|
+
"structuredClone failed, falling back to deepCopys",
|
|
236
|
+
e
|
|
237
|
+
);
|
|
238
|
+
return deepCopys(obj);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return deepCopys(obj);
|
|
242
|
+
}
|
|
243
|
+
function isPlainObject(obj) {
|
|
244
|
+
return obj !== null && typeof obj === "object" && obj.constructor === Object;
|
|
245
|
+
}
|
|
246
|
+
function simpleDeepCopy(obj) {
|
|
247
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
248
|
+
return obj;
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(obj)) {
|
|
251
|
+
return obj.map((item) => simpleDeepCopy(item));
|
|
252
|
+
}
|
|
253
|
+
if (obj instanceof Date) {
|
|
254
|
+
return new Date(obj.getTime());
|
|
255
|
+
}
|
|
256
|
+
if (obj instanceof RegExp) {
|
|
257
|
+
return new RegExp(obj.source, obj.flags);
|
|
258
|
+
}
|
|
259
|
+
const copy = {};
|
|
260
|
+
for (const key in obj) {
|
|
261
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
262
|
+
copy[key] = simpleDeepCopy(obj[key]);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return copy;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
exports.deepCopys = deepCopys; exports.safeDeepCopy = safeDeepCopy; exports.fastDeepCopy = fastDeepCopy; exports.structuredCloneCopy = structuredCloneCopy; exports.isPlainObject = isPlainObject; exports.simpleDeepCopy = simpleDeepCopy;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQHMO7DUJcjs = require('./chunk-QHMO7DUJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk3QR3J6AEcjs = require('./chunk-3QR3J6AE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk65O7KWP4cjs = require('./chunk-65O7KWP4.cjs');
|
|
@@ -15,8 +15,8 @@ var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
|
|
|
15
15
|
var basic_exports = {};
|
|
16
16
|
_chunk75ZPJI57cjs.__export.call(void 0, basic_exports, {
|
|
17
17
|
array: () => _chunk65O7KWP4cjs.array_exports,
|
|
18
|
-
object: () =>
|
|
19
|
-
string: () =>
|
|
18
|
+
object: () => _chunk3QR3J6AEcjs.object_exports,
|
|
19
|
+
string: () => _chunkQHMO7DUJcjs.string_exports
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setSort
|
|
3
|
+
} from "./chunk-3LWFUVER.js";
|
|
1
4
|
import {
|
|
2
5
|
unmergeObject
|
|
3
6
|
} from "./chunk-A6J46LQK.js";
|
|
7
|
+
import {
|
|
8
|
+
hasOwn
|
|
9
|
+
} from "./chunk-3IR2ABRO.js";
|
|
4
10
|
import {
|
|
5
11
|
mergeObject
|
|
6
12
|
} from "./chunk-RD4EP3M5.js";
|
|
@@ -11,24 +17,26 @@ import {
|
|
|
11
17
|
import {
|
|
12
18
|
reverseObj
|
|
13
19
|
} from "./chunk-B3IGSYZT.js";
|
|
14
|
-
import {
|
|
15
|
-
setSort
|
|
16
|
-
} from "./chunk-3LWFUVER.js";
|
|
17
20
|
import {
|
|
18
21
|
attrValueSort
|
|
19
22
|
} from "./chunk-T4BAVDTH.js";
|
|
20
23
|
import {
|
|
21
24
|
deepCopy
|
|
22
25
|
} from "./chunk-PHKZER72.js";
|
|
26
|
+
import {
|
|
27
|
+
deepCopys,
|
|
28
|
+
fastDeepCopy,
|
|
29
|
+
isPlainObject,
|
|
30
|
+
safeDeepCopy,
|
|
31
|
+
simpleDeepCopy,
|
|
32
|
+
structuredCloneCopy
|
|
33
|
+
} from "./chunk-YMKTU42G.js";
|
|
23
34
|
import {
|
|
24
35
|
filterObject
|
|
25
36
|
} from "./chunk-S42NGJ5W.js";
|
|
26
37
|
import {
|
|
27
38
|
getSort
|
|
28
39
|
} from "./chunk-ZEAT23CI.js";
|
|
29
|
-
import {
|
|
30
|
-
hasOwn
|
|
31
|
-
} from "./chunk-3IR2ABRO.js";
|
|
32
40
|
import {
|
|
33
41
|
isEqual,
|
|
34
42
|
isEqualEnhanced
|
|
@@ -48,6 +56,8 @@ var object_exports = {};
|
|
|
48
56
|
__export(object_exports, {
|
|
49
57
|
attrValueSort: () => attrValueSort,
|
|
50
58
|
deepCopy: () => deepCopy,
|
|
59
|
+
deepCopys: () => deepCopys,
|
|
60
|
+
fastDeepCopy: () => fastDeepCopy,
|
|
51
61
|
filterObject: () => filterObject,
|
|
52
62
|
getObjValue: () => getObjValue,
|
|
53
63
|
getSort: () => getSort,
|
|
@@ -56,10 +66,14 @@ __export(object_exports, {
|
|
|
56
66
|
isEqualEnhanced: () => isEqualEnhanced,
|
|
57
67
|
isObject: () => isObject,
|
|
58
68
|
isObjectArray: () => isObjectArray,
|
|
69
|
+
isPlainObject: () => isPlainObject,
|
|
59
70
|
mergeObject: () => mergeObject,
|
|
60
71
|
reverseObj: () => reverseObj,
|
|
72
|
+
safeDeepCopy: () => safeDeepCopy,
|
|
61
73
|
setObjValue: () => setObjValue,
|
|
62
74
|
setSort: () => setSort,
|
|
75
|
+
simpleDeepCopy: () => simpleDeepCopy,
|
|
76
|
+
structuredCloneCopy: () => structuredCloneCopy,
|
|
63
77
|
unmergeObject: () => unmergeObject
|
|
64
78
|
});
|
|
65
79
|
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
matchs
|
|
3
|
-
} from "./chunk-T2QKEABG.js";
|
|
4
|
-
import {
|
|
5
|
-
matchsEnd
|
|
6
|
-
} from "./chunk-YNOFNHEK.js";
|
|
7
|
-
import {
|
|
8
|
-
matchsStart
|
|
9
|
-
} from "./chunk-S6JRKYPY.js";
|
|
10
|
-
import {
|
|
11
|
-
matchsWhole
|
|
12
|
-
} from "./chunk-IRGCP7KH.js";
|
|
13
1
|
import {
|
|
14
2
|
isAlphaNumeric,
|
|
15
3
|
isBankCode,
|
|
@@ -37,6 +25,18 @@ import {
|
|
|
37
25
|
isURL,
|
|
38
26
|
isWeChat
|
|
39
27
|
} from "./chunk-PLNZCEDI.js";
|
|
28
|
+
import {
|
|
29
|
+
matchs
|
|
30
|
+
} from "./chunk-33X65PQS.js";
|
|
31
|
+
import {
|
|
32
|
+
matchsWhole
|
|
33
|
+
} from "./chunk-IRGCP7KH.js";
|
|
34
|
+
import {
|
|
35
|
+
matchsEnd
|
|
36
|
+
} from "./chunk-YNOFNHEK.js";
|
|
37
|
+
import {
|
|
38
|
+
matchsStart
|
|
39
|
+
} from "./chunk-S6JRKYPY.js";
|
|
40
40
|
import {
|
|
41
41
|
__export
|
|
42
42
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// packages/basic/object/deepCopys.ts
|
|
2
|
+
function deepCopys(obj, options = {}) {
|
|
3
|
+
const {
|
|
4
|
+
visited = /* @__PURE__ */ new WeakMap(),
|
|
5
|
+
maxDepth = 100,
|
|
6
|
+
handleProxy = "unwrap",
|
|
7
|
+
currentDepth = 0
|
|
8
|
+
} = options;
|
|
9
|
+
if (currentDepth >= maxDepth) {
|
|
10
|
+
console.warn("deepCopys: Maximum depth reached, returning reference");
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
if (typeof obj === "function") {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
if (visited.has(obj)) {
|
|
20
|
+
return visited.get(obj);
|
|
21
|
+
}
|
|
22
|
+
const isProxy = isProxyObject(obj);
|
|
23
|
+
if (isProxy) {
|
|
24
|
+
switch (handleProxy) {
|
|
25
|
+
case "unwrap":
|
|
26
|
+
const rawValue = getProxyTarget(obj);
|
|
27
|
+
if (rawValue !== obj) {
|
|
28
|
+
return deepCopys(rawValue, {
|
|
29
|
+
visited,
|
|
30
|
+
maxDepth,
|
|
31
|
+
handleProxy,
|
|
32
|
+
currentDepth: currentDepth + 1
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
case "clone":
|
|
37
|
+
const target = getProxyTarget(obj);
|
|
38
|
+
if (target !== obj) {
|
|
39
|
+
const result = deepCopys(target, {
|
|
40
|
+
visited,
|
|
41
|
+
maxDepth,
|
|
42
|
+
handleProxy,
|
|
43
|
+
currentDepth: currentDepth + 1
|
|
44
|
+
});
|
|
45
|
+
visited.set(obj, result);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case "keep":
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (obj instanceof Date) {
|
|
54
|
+
const copy = new Date(obj.getTime());
|
|
55
|
+
visited.set(obj, copy);
|
|
56
|
+
return copy;
|
|
57
|
+
}
|
|
58
|
+
if (obj instanceof RegExp) {
|
|
59
|
+
const copy = new RegExp(obj.source, obj.flags);
|
|
60
|
+
visited.set(obj, copy);
|
|
61
|
+
return copy;
|
|
62
|
+
}
|
|
63
|
+
if (obj instanceof Map) {
|
|
64
|
+
const copy = /* @__PURE__ */ new Map();
|
|
65
|
+
visited.set(obj, copy);
|
|
66
|
+
obj.forEach((value, key) => {
|
|
67
|
+
copy.set(
|
|
68
|
+
deepCopys(key, {
|
|
69
|
+
visited,
|
|
70
|
+
maxDepth,
|
|
71
|
+
handleProxy,
|
|
72
|
+
currentDepth: currentDepth + 1
|
|
73
|
+
}),
|
|
74
|
+
deepCopys(value, {
|
|
75
|
+
visited,
|
|
76
|
+
maxDepth,
|
|
77
|
+
handleProxy,
|
|
78
|
+
currentDepth: currentDepth + 1
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
return copy;
|
|
83
|
+
}
|
|
84
|
+
if (obj instanceof Set) {
|
|
85
|
+
const copy = /* @__PURE__ */ new Set();
|
|
86
|
+
visited.set(obj, copy);
|
|
87
|
+
obj.forEach((value) => {
|
|
88
|
+
copy.add(
|
|
89
|
+
deepCopys(value, {
|
|
90
|
+
visited,
|
|
91
|
+
maxDepth,
|
|
92
|
+
handleProxy,
|
|
93
|
+
currentDepth: currentDepth + 1
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
return copy;
|
|
98
|
+
}
|
|
99
|
+
if (obj instanceof ArrayBuffer) {
|
|
100
|
+
const copy = obj.slice(0);
|
|
101
|
+
visited.set(obj, copy);
|
|
102
|
+
return copy;
|
|
103
|
+
}
|
|
104
|
+
if (ArrayBuffer.isView(obj)) {
|
|
105
|
+
const copy = obj.slice();
|
|
106
|
+
visited.set(obj, copy);
|
|
107
|
+
return copy;
|
|
108
|
+
}
|
|
109
|
+
if (isPromise(obj)) {
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
const objClone = Array.isArray(obj) ? [] : {};
|
|
113
|
+
visited.set(obj, objClone);
|
|
114
|
+
const keys = getAllPropertyKeys(obj);
|
|
115
|
+
for (const key of keys) {
|
|
116
|
+
try {
|
|
117
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
118
|
+
obj,
|
|
119
|
+
key
|
|
120
|
+
);
|
|
121
|
+
if (descriptor && descriptor.get) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const value = obj[key];
|
|
125
|
+
objClone[key] = deepCopys(value, {
|
|
126
|
+
visited,
|
|
127
|
+
maxDepth,
|
|
128
|
+
handleProxy,
|
|
129
|
+
currentDepth: currentDepth + 1
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return objClone;
|
|
136
|
+
}
|
|
137
|
+
function isProxyObject(obj) {
|
|
138
|
+
if (!obj || typeof obj !== "object") return false;
|
|
139
|
+
try {
|
|
140
|
+
if (obj && obj.__v_isReactive || obj.__v_isReadonly) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const str = Object.prototype.toString.call(obj);
|
|
147
|
+
if (str === "[object Proxy]") {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
function getProxyTarget(obj) {
|
|
155
|
+
if (!obj || typeof obj !== "object") return obj;
|
|
156
|
+
try {
|
|
157
|
+
const raw = obj.__v_raw;
|
|
158
|
+
if (raw !== void 0) {
|
|
159
|
+
return raw;
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
return obj;
|
|
164
|
+
}
|
|
165
|
+
function isPromise(obj) {
|
|
166
|
+
return obj && typeof obj === "object" && typeof obj.then === "function";
|
|
167
|
+
}
|
|
168
|
+
function getAllPropertyKeys(obj) {
|
|
169
|
+
const keys = [];
|
|
170
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
171
|
+
keys.push(...ownKeys);
|
|
172
|
+
return keys;
|
|
173
|
+
}
|
|
174
|
+
function safeDeepCopy(obj) {
|
|
175
|
+
try {
|
|
176
|
+
const rawObj = getRawReactiveValue(obj);
|
|
177
|
+
if (rawObj !== obj) {
|
|
178
|
+
return deepCopys(rawObj, {
|
|
179
|
+
handleProxy: "unwrap",
|
|
180
|
+
maxDepth: 50
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
} catch (error) {
|
|
184
|
+
}
|
|
185
|
+
return deepCopys(obj, {
|
|
186
|
+
handleProxy: "unwrap",
|
|
187
|
+
maxDepth: 50
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function getRawReactiveValue(obj) {
|
|
191
|
+
if (!obj || typeof obj !== "object") return obj;
|
|
192
|
+
try {
|
|
193
|
+
const raw = obj.__v_raw;
|
|
194
|
+
if (raw !== void 0) {
|
|
195
|
+
return raw;
|
|
196
|
+
}
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
if (obj.__ob__) {
|
|
201
|
+
const plainObj = { ...obj };
|
|
202
|
+
delete plainObj.__ob__;
|
|
203
|
+
return plainObj;
|
|
204
|
+
}
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
return obj;
|
|
208
|
+
}
|
|
209
|
+
function fastDeepCopy(obj) {
|
|
210
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
211
|
+
return obj;
|
|
212
|
+
}
|
|
213
|
+
if (obj instanceof Date) {
|
|
214
|
+
return new Date(obj.getTime());
|
|
215
|
+
}
|
|
216
|
+
if (obj instanceof RegExp) {
|
|
217
|
+
return new RegExp(obj.source, obj.flags);
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
return JSON.parse(JSON.stringify(obj));
|
|
221
|
+
} catch (e) {
|
|
222
|
+
console.warn("fastDeepCopy failed, falling back to deepCopys", e);
|
|
223
|
+
return deepCopys(obj, {
|
|
224
|
+
handleProxy: "unwrap",
|
|
225
|
+
maxDepth: 100
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function structuredCloneCopy(obj) {
|
|
230
|
+
if (typeof structuredClone === "function") {
|
|
231
|
+
try {
|
|
232
|
+
return structuredClone(obj);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.warn(
|
|
235
|
+
"structuredClone failed, falling back to deepCopys",
|
|
236
|
+
e
|
|
237
|
+
);
|
|
238
|
+
return deepCopys(obj);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return deepCopys(obj);
|
|
242
|
+
}
|
|
243
|
+
function isPlainObject(obj) {
|
|
244
|
+
return obj !== null && typeof obj === "object" && obj.constructor === Object;
|
|
245
|
+
}
|
|
246
|
+
function simpleDeepCopy(obj) {
|
|
247
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") {
|
|
248
|
+
return obj;
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(obj)) {
|
|
251
|
+
return obj.map((item) => simpleDeepCopy(item));
|
|
252
|
+
}
|
|
253
|
+
if (obj instanceof Date) {
|
|
254
|
+
return new Date(obj.getTime());
|
|
255
|
+
}
|
|
256
|
+
if (obj instanceof RegExp) {
|
|
257
|
+
return new RegExp(obj.source, obj.flags);
|
|
258
|
+
}
|
|
259
|
+
const copy = {};
|
|
260
|
+
for (const key in obj) {
|
|
261
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
262
|
+
copy[key] = simpleDeepCopy(obj[key]);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return copy;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export {
|
|
269
|
+
deepCopys,
|
|
270
|
+
safeDeepCopy,
|
|
271
|
+
fastDeepCopy,
|
|
272
|
+
structuredCloneCopy,
|
|
273
|
+
isPlainObject,
|
|
274
|
+
simpleDeepCopy
|
|
275
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { attrValueSort } from './basic/object/attrValueSort.cjs';
|
|
2
2
|
import { deepCopy } from './basic/object/deepCopy.cjs';
|
|
3
|
+
import { deepCopys, fastDeepCopy, isPlainObject, safeDeepCopy, simpleDeepCopy, structuredCloneCopy } from './basic/object/deepCopys.cjs';
|
|
3
4
|
import { filterObject } from './basic/object/filterObject.cjs';
|
|
4
5
|
import { getSort } from './basic/object/getSort.cjs';
|
|
5
6
|
import { hasOwn } from './basic/object/hasOwn.cjs';
|
|
@@ -14,6 +15,8 @@ import { unmergeObject } from './basic/object/unmergeObject.cjs';
|
|
|
14
15
|
|
|
15
16
|
declare const index_attrValueSort: typeof attrValueSort;
|
|
16
17
|
declare const index_deepCopy: typeof deepCopy;
|
|
18
|
+
declare const index_deepCopys: typeof deepCopys;
|
|
19
|
+
declare const index_fastDeepCopy: typeof fastDeepCopy;
|
|
17
20
|
declare const index_filterObject: typeof filterObject;
|
|
18
21
|
declare const index_getObjValue: typeof getObjValue;
|
|
19
22
|
declare const index_getSort: typeof getSort;
|
|
@@ -22,13 +25,17 @@ declare const index_isEqual: typeof isEqual;
|
|
|
22
25
|
declare const index_isEqualEnhanced: typeof isEqualEnhanced;
|
|
23
26
|
declare const index_isObject: typeof isObject;
|
|
24
27
|
declare const index_isObjectArray: typeof isObjectArray;
|
|
28
|
+
declare const index_isPlainObject: typeof isPlainObject;
|
|
25
29
|
declare const index_mergeObject: typeof mergeObject;
|
|
26
30
|
declare const index_reverseObj: typeof reverseObj;
|
|
31
|
+
declare const index_safeDeepCopy: typeof safeDeepCopy;
|
|
27
32
|
declare const index_setObjValue: typeof setObjValue;
|
|
28
33
|
declare const index_setSort: typeof setSort;
|
|
34
|
+
declare const index_simpleDeepCopy: typeof simpleDeepCopy;
|
|
35
|
+
declare const index_structuredCloneCopy: typeof structuredCloneCopy;
|
|
29
36
|
declare const index_unmergeObject: typeof unmergeObject;
|
|
30
37
|
declare namespace index {
|
|
31
|
-
export { index_attrValueSort as attrValueSort, index_deepCopy as deepCopy, index_filterObject as filterObject, index_getObjValue as getObjValue, index_getSort as getSort, index_hasOwn as hasOwn, index_isEqual as isEqual, index_isEqualEnhanced as isEqualEnhanced, index_isObject as isObject, index_isObjectArray as isObjectArray, index_mergeObject as mergeObject, index_reverseObj as reverseObj, index_setObjValue as setObjValue, index_setSort as setSort, index_unmergeObject as unmergeObject };
|
|
38
|
+
export { index_attrValueSort as attrValueSort, index_deepCopy as deepCopy, index_deepCopys as deepCopys, index_fastDeepCopy as fastDeepCopy, index_filterObject as filterObject, index_getObjValue as getObjValue, index_getSort as getSort, index_hasOwn as hasOwn, index_isEqual as isEqual, index_isEqualEnhanced as isEqualEnhanced, index_isObject as isObject, index_isObjectArray as isObjectArray, index_isPlainObject as isPlainObject, index_mergeObject as mergeObject, index_reverseObj as reverseObj, index_safeDeepCopy as safeDeepCopy, index_setObjValue as setObjValue, index_setSort as setSort, index_simpleDeepCopy as simpleDeepCopy, index_structuredCloneCopy as structuredCloneCopy, index_unmergeObject as unmergeObject };
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
export { index as i };
|