diff options
Diffstat (limited to 'packages/idb-bridge/src/util/structuredClone.ts')
-rw-r--r-- | packages/idb-bridge/src/util/structuredClone.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/idb-bridge/src/util/structuredClone.ts b/packages/idb-bridge/src/util/structuredClone.ts new file mode 100644 index 000000000..8b6b61315 --- /dev/null +++ b/packages/idb-bridge/src/util/structuredClone.ts @@ -0,0 +1,15 @@ + +function structuredCloneImpl(val: any, visited: WeakMap<any, boolean>): any { + // FIXME: replace with real implementation! + return JSON.parse(JSON.stringify(val)); +} + +/** + * Structured clone for IndexedDB. + */ +export function structuredClone(val: any): any { + const visited: WeakMap<any, boolean> = new WeakMap<any, boolean>(); + return structuredCloneImpl(val, visited); +} + +export default structuredClone;
\ No newline at end of file |