8 lines
183 B
TypeScript
8 lines
183 B
TypeScript
export function cloneValue<T>(value: T): T {
|
|
if (typeof structuredClone === 'function') {
|
|
return structuredClone(value);
|
|
}
|
|
|
|
return JSON.parse(JSON.stringify(value)) as T;
|
|
}
|