leaderboard / src /lib /eloInterval.ts
dbonet's picture paumateo's picture
Publish TabBioMed leaderboard
d189f56
Raw History Blame Contribute Delete
479 Bytes
import type { LeaderboardEntry } from '../types/benchmark';
export function hasEloInterval(
entry: LeaderboardEntry,
): entry is LeaderboardEntry & { eloLo: number; eloHi: number } {
return entry.eloLo !== null && entry.eloHi !== null && entry.eloHi > entry.eloLo;
}
export function formatEloInterval(entry: LeaderboardEntry, digits = 0): string | null {
return hasEloInterval(entry)
? `[${entry.eloLo.toFixed(digits)}, ${entry.eloHi.toFixed(digits)}]`
: null;
}