Create separate ScriptableDialogBase (#22974)

* Create separate ScriptableDialogBase

* more
This commit is contained in:
Charles Gagnon
2023-05-05 09:17:51 -07:00
committed by GitHub
parent 9af7a049e6
commit c3bf85f026
14 changed files with 236 additions and 169 deletions

View File

@@ -68,3 +68,22 @@ export function equals(one: any, other: any, strictArrayCompare: boolean = true)
}
return true;
}
export function deepClone<T>(obj: T): T {
if (!obj || typeof obj !== 'object') {
return obj;
}
if (obj instanceof RegExp) {
// See https://github.com/Microsoft/TypeScript/issues/10990
return obj as any;
}
const result: any = Array.isArray(obj) ? [] : {};
Object.keys(<any>obj).forEach((key: string) => {
if ((<any>obj)[key] && typeof (<any>obj)[key] === 'object') {
result[key] = deepClone((<any>obj)[key]);
} else {
result[key] = (<any>obj)[key];
}
});
return result;
}