core/selectors/catalog.selector.ts

core/selectors/catalog.selector.ts is a file in GovLab Quality. 10 lines of code and 2 definitions.

import type { CatalogRule } from "#types/catalog.types";

export const distinctRules = function distinctRules(rules: readonly CatalogRule[]): CatalogRule[] {
    const byId = new Map<string, CatalogRule>();
    for (const rule of rules) {
        if (!byId.has(rule.ruleId)) {
            byId.set(rule.ruleId, rule);
        }
    }
    return [...byId.values()];
};