Files
NapCatQQ/.pnpm-store/v3/files/66/d76fc6595312b23692b8400fdafb844f8a12c14696663a00b0947adf558ddb73a30184686bda19d59882263e10ad166a15601d9dc2eee92bb5b274fab032a9
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

43 lines
1.7 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntersectEvaluated = IntersectEvaluated;
const index_1 = require("../symbols/index");
const type_1 = require("../create/type");
const index_2 = require("../discard/index");
const index_3 = require("../never/index");
const index_4 = require("../optional/index");
const intersect_create_1 = require("./intersect-create");
// ------------------------------------------------------------------
// TypeGuard
// ------------------------------------------------------------------
const kind_1 = require("../guard/kind");
// prettier-ignore
function IsIntersectOptional(types) {
return types.every(left => (0, kind_1.IsOptional)(left));
}
// prettier-ignore
function RemoveOptionalFromType(type) {
return ((0, index_2.Discard)(type, [index_1.OptionalKind]));
}
// prettier-ignore
function RemoveOptionalFromRest(types) {
return types.map(left => (0, kind_1.IsOptional)(left) ? RemoveOptionalFromType(left) : left);
}
// prettier-ignore
function ResolveIntersect(types, options) {
return (IsIntersectOptional(types)
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(types), options))
: (0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(types), options));
}
/** `[Json]` Creates an evaluated Intersect type */
function IntersectEvaluated(types, options = {}) {
if (types.length === 1)
return (0, type_1.CreateType)(types[0], options);
if (types.length === 0)
return (0, index_3.Never)(options);
if (types.some((schema) => (0, kind_1.IsTransform)(schema)))
throw new Error('Cannot intersect transform types');
return ResolveIntersect(types, options);
}