19 lines
470 B
TypeScript
19 lines
470 B
TypeScript
/**
|
|
* NumberDisplay
|
|
*
|
|
* Deterministic number formatting for display.
|
|
* Avoids Intl and toLocaleString to prevent SSR/hydration mismatches.
|
|
*/
|
|
|
|
export class NumberDisplay {
|
|
/**
|
|
* Formats a number with thousands separators (commas).
|
|
* Example: 1234567 -> "1,234,567"
|
|
*/
|
|
static format(value: number): string {
|
|
const parts = value.toString().split('.');
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
return parts.join('.');
|
|
}
|
|
}
|