Add deepCopy utility and enforce required fields in particle forms

This commit is contained in:
2025-12-27 22:06:45 +01:00
parent 9b8c4891f4
commit dc1b29e52c
3 changed files with 23 additions and 5 deletions
+10
View File
@@ -0,0 +1,10 @@
export function deepCopy<T>(obj: T): T {
// Structured cloning
if (typeof globalThis?.structuredClone === 'function') {
// @ts-ignore
return globalThis.structuredClone(obj) as T;
}
// Normal objects
return JSON.parse(JSON.stringify(obj)) as T;
}