Skip to content

Commit

Permalink
Remove extra casts and switch to use Object.entries (#163900)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Oct 18, 2022
1 parent 42d9928 commit 5170238
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/vs/base/common/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ export function deepClone<T>(obj: T): T {
return obj;
}
if (obj instanceof RegExp) {
// See https://github.com/microsoft/TypeScript/issues/10990
return obj as any;
return obj;
}
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];
}
Object.entries(obj).forEach(([key, value]) => {
result[key] = value && typeof value === 'object' ? deepClone(value) : value;
});
return result;
}
Expand Down

0 comments on commit 5170238

Please sign in to comment.