All files / app-leaderboard/src rulesets.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                  183x       22x 927x  
import { RULESET_IDS } from '@be-music/player-engine/ruleset';
/**
 * The shared rulesets in display order: the one list the database enums, API schemas and pages read.
 */
export { RULESET_IDS };
 
export type RulesetId = (typeof RULESET_IDS)[number];
 
export function isRuleset(value: string | undefined): value is RulesetId {
  return value !== undefined && (RULESET_IDS as readonly string[]).includes(value);
}
 
/** Orders anything keyed by ruleset in {@link RULESET_IDS} order. */
export const byRulesetOrder = (left: { ruleset: string }, right: { ruleset: string }): number =>
  (RULESET_IDS as readonly string[]).indexOf(left.ruleset) - (RULESET_IDS as readonly string[]).indexOf(right.ruleset);