signal-desktop/ts/util/deepClone.ts
Fedor Indutny 3555ccc629
Make most message attribute uses readonly
Co-authored-by: Jamie Kyle <jamie@signal.org>
2024-07-24 13:14:11 -07:00

11 lines
391 B
TypeScript

// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { WritableDeep } from 'type-fest';
/**
* Takes a readonly object and returns a writable deep clone of it.
* @see https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
*/
export function deepClone<T>(value: T): WritableDeep<T> {
return structuredClone(value) as WritableDeep<T>;
}