25 lines
617 B
TypeScript
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)}`;
|
|
}
|
|
}
|