MCPcopy
hub / github.com/dubinc/dub / currencyFormatter

Function currencyFormatter

packages/utils/src/functions/currency-formatter.ts:8–24  ·  view source on GitHub ↗
(
  valueInCents: number | bigint,
  options?: CurrencyFormatterOptions,
)

Source from the content-addressed store, hash-verified

6}
7
8export const currencyFormatter = (
9 valueInCents: number | bigint,
10 options?: CurrencyFormatterOptions,
11) => {
12 const cents = toCentsNumber(valueInCents);
13 const currency = options?.currency || "USD";
14 return Intl.NumberFormat("en-US", {
15 style: "currency",
16 currency,
17 trailingZeroDisplay: isZeroDecimalCurrency(currency)
18 ? "stripIfInteger"
19 : "auto",
20 ...options,
21 } as CurrencyFormatterOptions).format(
22 isZeroDecimalCurrency(currency) ? cents : cents / 100,
23 );
24};

Callers 15

PartnerPayoutConfirmedFunction · 0.90
PartnerPayoutFailedFunction · 0.90
PartnerTremendousPayoutFunction · 0.90
ConnectPayoutReminderFunction · 0.90
PartnerProgramSummaryFunction · 0.90
DomainRenewalReminderFunction · 0.90
NewSaleAlertProgramOwnerFunction · 0.90
ProgramPayoutReminderFunction · 0.90

Calls 2

toCentsNumberFunction · 0.90
isZeroDecimalCurrencyFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…