(
price: number | string,
options: {
currency?: 'USD' | 'EUR' | 'GBP' | 'BDT'
notation?: Intl.NumberFormatOptions['notation']
} = {}
)
| 7 | } |
| 8 | |
| 9 | export function formatPrice( |
| 10 | price: number | string, |
| 11 | options: { |
| 12 | currency?: 'USD' | 'EUR' | 'GBP' | 'BDT' |
| 13 | notation?: Intl.NumberFormatOptions['notation'] |
| 14 | } = {} |
| 15 | ) { |
| 16 | const { currency = 'USD', notation = 'compact' } = options |
| 17 | |
| 18 | const numericPrice = |
| 19 | typeof price === 'string' ? parseFloat(price) : price |
| 20 | |
| 21 | return new Intl.NumberFormat('en-US', { |
| 22 | style: 'currency', |
| 23 | currency, |
| 24 | notation, |
| 25 | maximumFractionDigits: 2, |
| 26 | }).format(numericPrice) |
| 27 | } |
| 28 | |
| 29 | export function constructMetadata({ |
| 30 | title = 'DigitalHippo - the marketplace for digital assets', |
no outgoing calls
no test coverage detected