The number to format.
If true, adds a dollar sign prefix. If a string, uses it as the prefix.
Options for decimal places.
Optional
1?: numberHow many decimals there should be when there is 1 digit.
Optional
2?: numberHow many decimals there should be when there are 2 digits.
Optional
3?: numberHow many decimals there should be when there are 3 digits.
Optional
decimalPlaces: number = 0The number of decimal places to use when there is no suffix.
Optional
precision: number = 100The precision to use for the Decimal instance. Defaults to 100.
The formatted number.
numberFormatter_compact(123456789, true); // "$123M"
numberFormatter_compact(123456789, "€"); // "€123M"
numberFormatter_compact(12345678); // "12.3M"
numberFormatter_compact(123456789, false, { 3: 5 }); // "123.45678M"
numberFormatter_compact(12345678, false, { 3: 5 }); // "12.3M"
numberFormatter_compact(12345678, false, { 2: 3 });
Formats a number into a compact string representation.