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

60 lines
1.6 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetIncludes = SetIncludes;
exports.SetIsSubset = SetIsSubset;
exports.SetDistinct = SetDistinct;
exports.SetIntersect = SetIntersect;
exports.SetUnion = SetUnion;
exports.SetComplement = SetComplement;
exports.SetIntersectMany = SetIntersectMany;
exports.SetUnionMany = SetUnionMany;
/** Returns true if element right is in the set of left */
// prettier-ignore
function SetIncludes(T, S) {
return T.includes(S);
}
/** Returns true if left is a subset of right */
function SetIsSubset(T, S) {
return T.every((L) => SetIncludes(S, L));
}
/** Returns a distinct set of elements */
function SetDistinct(T) {
return [...new Set(T)];
}
/** Returns the Intersect of the given sets */
function SetIntersect(T, S) {
return T.filter((L) => S.includes(L));
}
/** Returns the Union of the given sets */
function SetUnion(T, S) {
return [...T, ...S];
}
/** Returns the Complement by omitting elements in T that are in S */
// prettier-ignore
function SetComplement(T, S) {
return T.filter(L => !S.includes(L));
}
// prettier-ignore
function SetIntersectManyResolve(T, Init) {
return T.reduce((Acc, L) => {
return SetIntersect(Acc, L);
}, Init);
}
// prettier-ignore
function SetIntersectMany(T) {
return (T.length === 1
? T[0]
// Use left to initialize the accumulator for resolve
: T.length > 1
? SetIntersectManyResolve(T.slice(1), T[0])
: []);
}
/** Returns the Union of multiple sets */
function SetUnionMany(T) {
const Acc = [];
for (const L of T)
Acc.push(...L);
return Acc;
}