UNPKG

@e-group/utils

Version:

eGroup team utils that share across projects.

19 lines (16 loc) 498 B
/** * format currency */ const ccyformat = (currency, options = {}) => { const round = options.round, _options$maximumFract = options.maximumFractionDigits, maximumFractionDigits = _options$maximumFract === void 0 ? 6 : _options$maximumFract; let nextCurrency = Number(Number(currency).toFixed(6)); if (round) { nextCurrency = Math.round(nextCurrency); } return nextCurrency.toLocaleString(undefined, { maximumFractionDigits }); }; export default ccyformat;