Files
NapCatQQ/.pnpm-store/v3/files/5f/ed4288f641fdc57189e48ec03f97c3aa2024e875ccdcb539f44be076c23eb2675fde627340b7f12399c1eebf34023588f37b650081a9045b6e74bdb172ce68
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

38 lines
1.4 KiB
Plaintext

import { TypeRegistry, FormatRegistry } from '../type/registry/index.mjs';
import { Unsafe } from '../type/unsafe/index.mjs';
import { Kind } from '../type/symbols/index.mjs';
import { TypeBoxError } from '../type/error/index.mjs';
// ------------------------------------------------------------------
// Errors
// ------------------------------------------------------------------
export class TypeSystemDuplicateTypeKind extends TypeBoxError {
constructor(kind) {
super(`Duplicate type kind '${kind}' detected`);
}
}
export class TypeSystemDuplicateFormat extends TypeBoxError {
constructor(kind) {
super(`Duplicate string format '${kind}' detected`);
}
}
/** Creates user defined types and formats and provides overrides for value checking behaviours */
export var TypeSystem;
(function (TypeSystem) {
/** Creates a new type */
function Type(kind, check) {
if (TypeRegistry.Has(kind))
throw new TypeSystemDuplicateTypeKind(kind);
TypeRegistry.Set(kind, check);
return (options = {}) => Unsafe({ ...options, [Kind]: kind });
}
TypeSystem.Type = Type;
/** Creates a new string format */
function Format(format, check) {
if (FormatRegistry.Has(format))
throw new TypeSystemDuplicateFormat(format);
FormatRegistry.Set(format, check);
return format;
}
TypeSystem.Format = Format;
})(TypeSystem || (TypeSystem = {}));