@jeremyckahn/farmhand
Version:
A farming game
16 lines (13 loc) • 396 B
text/typescript
import { dinero, toDecimal, USD } from 'dinero.js'
/**
* @returns Include dollar sign and other formatting, as well as cents.
*/
export const moneyString = (number: number): string =>
toDecimal(
dinero({ amount: Math.round(number * 100), currency: USD }),
({ value }) =>
Number(value).toLocaleString('en-US', {
style: 'currency',
currency: 'USD',
})
)