Files
gridpilot.gg/apps/website/lib/formatters/FinishFormatter.ts
2026-01-24 01:07:43 +01:00

25 lines
617 B
TypeScript

/**
* FinishDisplay
*
* Deterministic formatting for race finish positions.
*/
export class FinishFormatter {
/**
* Formats a finish position as "P1", "P2", etc.
*/
static format(position: number | null | undefined): string {
if (position === null || position === undefined) return '—';
return `P${position.toFixed(0)}`;
}
/**
* Formats an average finish position with one decimal place.
* Example: 5.4 -> "P5.4"
*/
static formatAverage(avg: number | null | undefined): string {
if (avg === null || avg === undefined) return '—';
return `P${avg.toFixed(1)}`;
}
}