From 19359529e987ea0c5536038ed8038eb62f252876 Mon Sep 17 00:00:00 2001 From: Beef Date: Tue, 17 Jan 2023 08:02:27 +0000 Subject: [PATCH] [Utils > unfreeze] Add --- src/lib/utils/unfreeze.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/lib/utils/unfreeze.ts diff --git a/src/lib/utils/unfreeze.ts b/src/lib/utils/unfreeze.ts new file mode 100644 index 0000000..1e12e44 --- /dev/null +++ b/src/lib/utils/unfreeze.ts @@ -0,0 +1,8 @@ +// https://stackoverflow.com/a/68339174 + +export function unfreeze(obj: object) { + if (Object.isFrozen(obj)) { + return Object.assign({}, obj); + } + return obj; +} \ No newline at end of file