formatCompact
Formats a number using compact notation (e.g. 1_500_000 → "1.5M").
Thin wrapper over Intl.NumberFormat with notation: 'compact'. Companion
of formatSize in the same format* family.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | number | The number to format. |
locale | string | BCP 47 locale tag. Defaults to the runtime locale. (optional) |
Returns
Section titled “Returns”string — A compact string representation of the number.
Examples
Section titled “Examples”Compact large numbers
Section titled “Compact large numbers”Formats a number using K / M suffixes for readability.
Locale-aware formatting
Section titled “Locale-aware formatting”Uses the provided locale for the decimal separator and suffix.
