Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit a6dcfdf

Browse files
authored
Fix monaco enum suggestions by deep copying arrays properly (#434)
1 parent 2e4100c commit a6dcfdf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nodecg-io-core/dashboard/utils/deepCopy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
*/
88
export function objectDeepCopy<T extends Object>(obj: T | any): T {
99
if (typeof obj === "object") {
10-
const copy = {} as any;
11-
for (var attr in obj) {
12-
if (obj.hasOwnProperty(attr)) copy[attr] = objectDeepCopy(obj[attr]);
10+
if (Array.isArray(obj)) {
11+
return obj.map((entry) => objectDeepCopy(entry)) as any;
12+
} else {
13+
const copy = {} as any;
14+
for (var attr in obj) {
15+
if (obj.hasOwnProperty(attr)) copy[attr] = objectDeepCopy(obj[attr]);
16+
}
17+
return copy;
1318
}
14-
return copy;
1519
} else {
1620
return obj;
1721
}

0 commit comments

Comments
 (0)