From 4f5d41fab603fc7e27b36bb2587456430c5989b0 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Thu, 26 Jun 2025 11:36:36 +0200 Subject: [PATCH] clone impl --- frontend/src/lib/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 1b4e663661..65dc8a2383 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -1432,6 +1432,12 @@ export function scroll_into_view_if_needed_polyfill(elem: Element, centerIfNeede return observer // return for testing } +export function clone(t: T): T { + if (typeof t === 'function') throw new Error('Cannot clone a function') + if (typeof t === 'object') return stateSnapshot(t) as T + return t +} + export const editorPositionMap: Record = {} export type S3Uri = `s3://${string}/${string}`