formatNumberForDisplay
Stentor API Reference / stentor-utils/src / formatNumberForDisplay
Function: formatNumberForDisplay()
formatNumberForDisplay(
number,format?):string
Defined in: packages/stentor-utils/src/number.ts:165
Format numbers for display. The format is the subset of numeral's that this code base used
(numeral itself is gone): an optional leading $, 0,0 for thousands grouping, .0/.00
for the decimals shown (rounded), and an optional trailing % that multiplies by 100.
Anything not a finite number renders as 0, as numeral did. Any other format string throws:
numeral's optional decimals ("0.[00]"), abbreviations ("0.0a") and ordinals ("0o") are not
rendered, and misreading them silently would be worse than refusing them.
Parameters​
number​
string | number
The number to format
format?​
string = "0,0"
The format, defaults to "0,0" (so 10000 -> "10,000")
Returns​
string