Add deepCopy utility and enforce required fields in particle forms
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user