MCPcopy
hub / github.com/joschan21/digitalhippo / formatPrice

Function formatPrice

src/lib/utils.ts:9–27  ·  view source on GitHub ↗
(
  price: number | string,
  options: {
    currency?: 'USD' | 'EUR' | 'GBP' | 'BDT'
    notation?: Intl.NumberFormatOptions['notation']
  } = {}
)

Source from the content-addressed store, hash-verified

7}
8
9export 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
29export function constructMetadata({
30 title = 'DigitalHippo - the marketplace for digital assets',

Callers 7

CartFunction · 0.90
ProductListingFunction · 0.90
CartItemFunction · 0.90
ReceiptEmailFunction · 0.90
ThankYouPageFunction · 0.90
PageFunction · 0.90
PageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected