Files
NapCatQQ/.pnpm-store/v3/files/1c/561d6b359b5fc79ff0ae245fae165994e692d1b7206fc8ac03ace9c81262c72583ec7f0e8b582f610a9e50d76345738a90e302b31b8b739092fe713c7e6169
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

19 lines
795 B
Plaintext

import { Literal } from '../literal/index.mjs';
import { Kind, Hint } from '../symbols/index.mjs';
import { Union } from '../union/index.mjs';
// ------------------------------------------------------------------
// ValueGuard
// ------------------------------------------------------------------
import { IsUndefined } from '../guard/value.mjs';
/** `[Json]` Creates a Enum type */
export function Enum(item, options) {
if (IsUndefined(item))
throw new Error('Enum undefined or empty');
const values1 = globalThis.Object.getOwnPropertyNames(item)
.filter((key) => isNaN(key))
.map((key) => item[key]);
const values2 = [...new Set(values1)];
const anyOf = values2.map((value) => Literal(value));
return Union(anyOf, { ...options, [Hint]: 'Enum' });
}