We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b77c30a commit c1805c3Copy full SHA for c1805c3
1 file changed
src/core/safe-clone-deep.ts
@@ -24,6 +24,24 @@ export function safeCloneDeep<T>(obj: T): T {
24
return obj.clone();
25
}
26
27
+ // Handle Maps
28
+ if (obj instanceof Map) {
29
+ const clonedMap = new Map();
30
+ for (const [key, value] of obj.entries()) {
31
+ clonedMap.set(key, safeCloneDeep(value));
32
+ }
33
+ return clonedMap as T;
34
35
+
36
+ // Handle Sets
37
+ if (obj instanceof Set) {
38
+ const clonedSet = new Set();
39
+ for (const value of obj.values()) {
40
+ clonedSet.add(safeCloneDeep(value));
41
42
+ return clonedSet as T;
43
44
45
// Handle regular objects
46
const result = {} as T;
47
for (const key in obj) {
0 commit comments