website refactor
This commit is contained in:
18
apps/website/lib/display-objects/NumberDisplay.ts
Normal file
18
apps/website/lib/display-objects/NumberDisplay.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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('.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user