import type { IntersectTuple } from '../../utils/types/utility.type'; import type { AnyRole } from '../types/utility.type'; export function intersectRoles< Pool extends readonly AnyRole[], Target extends readonly AnyRole[], >(pool: Pool, target: Target) { const set = new WeakSet(pool); return target.filter((role) => set.has(role)) as [ ...IntersectTuple, ]; }