MCPcopy Create free account
hub / github.com/WebDevSimplified/course-platform / formatPrice

Function formatPrice

src/lib/formatters.ts:11–20  ·  view source on GitHub ↗
(amount: number, { showZeroAsNumber = false } = {})

Source from the content-addressed store, hash-verified

9}
10
11export function formatPrice(amount: number, { showZeroAsNumber = false } = {}) {
12 const formatter = new Intl.NumberFormat(undefined, {
13 style: "currency",
14 currency: "USD",
15 minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
16 })
17
18 if (amount === 0 && !showZeroAsNumber) return "Free"
19 return formatter.format(amount)
20}
21
22const DATE_FORMATTER = new Intl.DateTimeFormat(undefined, {
23 dateStyle: "medium",

Callers 9

ProductTableFunction · 0.90
ProductCardFunction · 0.90
PriceFunction · 0.90
UserPurchaseTableFunction · 0.90
PurchaseTableFunction · 0.90
ProductPageFunction · 0.90
PriceFunction · 0.90
SuspenseBoundaryFunction · 0.90
AdminPageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected