Files
NapCatQQ/.pnpm-store/v3/files/c9/4b4f8993b6323a238c336da308b481ca9493def75f18ff8d676048319def44bd5692e10e9c4daf3c07d095107394d050f42d5a9a914bb2ce243b7cdc6e0d04
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

49 lines
1.3 KiB
Plaintext

/** Returns true if element right is in the set of left */
// prettier-ignore
export function SetIncludes(T, S) {
return T.includes(S);
}
/** Returns true if left is a subset of right */
export function SetIsSubset(T, S) {
return T.every((L) => SetIncludes(S, L));
}
/** Returns a distinct set of elements */
export function SetDistinct(T) {
return [...new Set(T)];
}
/** Returns the Intersect of the given sets */
export function SetIntersect(T, S) {
return T.filter((L) => S.includes(L));
}
/** Returns the Union of the given sets */
export function SetUnion(T, S) {
return [...T, ...S];
}
/** Returns the Complement by omitting elements in T that are in S */
// prettier-ignore
export 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
export 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 */
export function SetUnionMany(T) {
const Acc = [];
for (const L of T)
Acc.push(...L);
return Acc;
}