A helper function for currency formatting.
npm i -S cur@latest
cur(
figureToBeFormatted: number,
returnDollarsAndCents: boolean,
config: { thousandsSeparator: string, decimalSeparator: string }
) => string | undefined
import cur from 'cur'
`$${cur(1234.56)}`
// "$1,235"
`$${cur(1234.56, true)}`
// "$1,234.56"
cur
accepts an optional config
argument with two properties, thousandsSeparator
and decimalSeparator
.
'$' + cur(1234.56, true, { thousandsSeparator: "'", decimalSeparator: "," })
// "$1'234,56"