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

43 lines
1.2 KiB
Plaintext

import { IntersectEvaluated } from '../intersect/index.mjs';
import { IndexFromPropertyKeys } from '../indexed/index.mjs';
import { KeyOfPropertyKeys } from '../keyof/index.mjs';
import { Object } from '../object/index.mjs';
import { SetDistinct } from '../sets/index.mjs';
// ------------------------------------------------------------------
// TypeGuard
// ------------------------------------------------------------------
import { IsNever } from '../guard/kind.mjs';
// prettier-ignore
function CompositeKeys(T) {
const Acc = [];
for (const L of T)
Acc.push(...KeyOfPropertyKeys(L));
return SetDistinct(Acc);
}
// prettier-ignore
function FilterNever(T) {
return T.filter(L => !IsNever(L));
}
// prettier-ignore
function CompositeProperty(T, K) {
const Acc = [];
for (const L of T)
Acc.push(...IndexFromPropertyKeys(L, [K]));
return FilterNever(Acc);
}
// prettier-ignore
function CompositeProperties(T, K) {
const Acc = {};
for (const L of K) {
Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
}
return Acc;
}
// prettier-ignore
export function Composite(T, options) {
const K = CompositeKeys(T);
const P = CompositeProperties(T, K);
const R = Object(P, options);
return R;
}