This commit is contained in:
Viet An
2026-05-19 10:00:15 +07:00
parent 1283757903
commit 5768a8a9fb
7 changed files with 170 additions and 146 deletions

View File

@@ -73,9 +73,23 @@ export default defineNuxtPlugin(() => {
return val === undefined || val === null || val === "";
};
const toRawDeep = function (observed) {
const val = toRaw(observed);
if (val instanceof Date) return val;
if (Array.isArray(val)) return val.map(toRawDeep);
if (val === null) return null;
if (typeof val === "object") {
const entries = Object.entries(val).map(([key, val]) => [key, toRawDeep(val)]);
return Object.fromEntries(entries);
}
return val;
};
const copy = function (val) {
if (empty(val)) return val;
return JSON.parse(JSON.stringify(val));
return structuredClone(toRawDeep(val));
};
const clone = function (obj) {