mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Deep freeze an object's values directly (#10022)
This commit is contained in:
parent
b608103806
commit
cd7aa49a16
|
|
@ -343,10 +343,8 @@ export function deepFreeze<T>(obj: T): T {
|
|||
Object.freeze(obj);
|
||||
if (Array.isArray(obj)) {
|
||||
for (const elem of obj) deepFreeze(elem);
|
||||
return obj;
|
||||
}
|
||||
for (const key of Object.keys(obj)) {
|
||||
deepFreeze((obj as any)[key]);
|
||||
} else {
|
||||
for (const elem of Object.values(obj)) deepFreeze(elem);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user