Files
NapCatQQ/.pnpm-store/v3/files/51/468dad95f1b997d1d267c10f68cd59424d4ad70bfc5d716e512a60f951696a9488e9bba9ad6b471a5b23231d6d42c1ef2fc9bc2279b29b630144109a703299
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

37 lines
1.1 KiB
Plaintext

import * as ValueGuard from '../guard/value.mjs';
function ArrayType(value) {
return value.map((value) => Visit(value));
}
function DateType(value) {
return new Date(value.getTime());
}
function Uint8ArrayType(value) {
return new Uint8Array(value);
}
function RegExpType(value) {
return new RegExp(value.source, value.flags);
}
function ObjectType(value) {
const result = {};
for (const key of Object.getOwnPropertyNames(value)) {
result[key] = Visit(value[key]);
}
for (const key of Object.getOwnPropertySymbols(value)) {
result[key] = Visit(value[key]);
}
return result;
}
// prettier-ignore
function Visit(value) {
return (ValueGuard.IsArray(value) ? ArrayType(value) :
ValueGuard.IsDate(value) ? DateType(value) :
ValueGuard.IsUint8Array(value) ? Uint8ArrayType(value) :
ValueGuard.IsRegExp(value) ? RegExpType(value) :
ValueGuard.IsObject(value) ? ObjectType(value) :
value);
}
/** Clones a value */
export function Clone(value) {
return Visit(value);
}