Skip to content

Commit

Permalink
feat: prefer structuredClone api for cloning #980
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Feb 1, 2025
1 parent e49fe94 commit fdda5c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/editor/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export function deepCloneOmitKeys<T, K>(obj: T, omitKeys: (keyof K)[]): T {
}

export function deepClone<T>(obj: T): T {
if (typeof structuredClone === 'function') {
return structuredClone(obj)
}
if (!obj || typeof obj !== 'object') {
return obj
}
Expand Down

0 comments on commit fdda5c7

Please sign in to comment.