manifold/web/lib/util/format.ts

19 lines
460 B
TypeScript
Raw Normal View History

const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
maximumFractionDigits: 0,
minimumFractionDigits: 0,
})
export function formatMoney(amount: number) {
return 'M$ ' + formatter.format(amount).replace('$', '')
}
export function formatWithCommas(amount: number) {
return formatter.format(amount).replace('$', '')
2021-12-15 07:41:50 +00:00
}
export function formatPercent(zeroToOne: number) {
return Math.round(zeroToOne * 100) + '%'
}