UNPKG

@bitblit/ratchet-common

Version:

Common tools for general use

22 lines 857 B
export class CurrencyRatchet { constructor() { } static centToDollarFormat(cents, fractionDigits = 2) { return CurrencyRatchet.dollarFormat(cents / 100, fractionDigits); } static dollarFormat(dollars, fractionDigits = 2) { const rval = dollars === null || dollars === undefined ? 'Null' : '$' + dollars.toLocaleString('en-US', { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits }); return rval; } static dollarFormatNumberRange(range) { let rval = 'N/A'; if (range) { rval = range.low ? CurrencyRatchet.dollarFormat(range.low) : ' ^ '; rval += ' - '; rval += range.high ? CurrencyRatchet.dollarFormat(range.high) : ' ^ '; } return rval; } } //# sourceMappingURL=currency-ratchet.js.map