Files
NapCatQQ/.pnpm-store/v3/files/a0/bddd1686dde0e8de95e309f64f6058439a5ee0e5c347273ad071bebe8481ce2510867db3a64a6a434580792a9ff6fcbc1d482223e7cc9e95b4b09e1c5452a4
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

23 lines
917 B
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Enum = Enum;
const index_1 = require("../literal/index");
const index_2 = require("../symbols/index");
const index_3 = require("../union/index");
// ------------------------------------------------------------------
// ValueGuard
// ------------------------------------------------------------------
const value_1 = require("../guard/value");
/** `[Json]` Creates a Enum type */
function Enum(item, options) {
if ((0, value_1.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) => (0, index_1.Literal)(value));
return (0, index_3.Union)(anyOf, { ...options, [index_2.Hint]: 'Enum' });
}