@angular-devkit/core 9.1.3 → 9.1.4
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/package.json +1 -1
- package/src/utils/object.js +11 -9
package/package.json
CHANGED
package/src/utils/object.js
CHANGED
|
@@ -18,22 +18,24 @@ const copySymbol = Symbol();
|
|
|
18
18
|
// tslint:disable-next-line:no-any
|
|
19
19
|
function deepCopy(value) {
|
|
20
20
|
if (Array.isArray(value)) {
|
|
21
|
+
// tslint:disable-next-line:no-any
|
|
21
22
|
return value.map((o) => deepCopy(o));
|
|
22
23
|
}
|
|
23
24
|
else if (value && typeof value === 'object') {
|
|
24
|
-
|
|
25
|
+
const valueCasted = value;
|
|
26
|
+
if (valueCasted[copySymbol]) {
|
|
25
27
|
// This is a circular dependency. Just return the cloned value.
|
|
26
|
-
return
|
|
28
|
+
return valueCasted[copySymbol];
|
|
27
29
|
}
|
|
28
|
-
if (
|
|
29
|
-
return JSON.parse(
|
|
30
|
+
if (valueCasted['toJSON']) {
|
|
31
|
+
return JSON.parse(valueCasted['toJSON']());
|
|
30
32
|
}
|
|
31
|
-
const copy = new (Object.getPrototypeOf(
|
|
32
|
-
|
|
33
|
-
for (const key of Object.getOwnPropertyNames(
|
|
34
|
-
copy[key] = deepCopy(
|
|
33
|
+
const copy = new (Object.getPrototypeOf(valueCasted).constructor)();
|
|
34
|
+
valueCasted[copySymbol] = copy;
|
|
35
|
+
for (const key of Object.getOwnPropertyNames(valueCasted)) {
|
|
36
|
+
copy[key] = deepCopy(valueCasted[key]);
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
valueCasted[copySymbol] = undefined;
|
|
37
39
|
return copy;
|
|
38
40
|
}
|
|
39
41
|
else {
|