MCPcopy Index your code
hub / github.com/coder/coder / formatCostMicros

Function formatCostMicros

site/src/utils/currency.ts:36–53  ·  view source on GitHub ↗
(micros: number | string)

Source from the content-addressed store, hash-verified

34}
35
36export function formatCostMicros(micros: number | string): string {
37 const microsValue = Number(micros);
38 if (!Number.isFinite(microsValue)) {
39 return "$0.00";
40 }
41
42 const dollars = Math.abs(microsValue) / MICROS_PER_DOLLAR;
43 const rounded4 = Number(dollars.toFixed(4));
44 if (rounded4 > 0 && rounded4 < 0.01) {
45 if (microsValue < 0) {
46 return `-$${dollars.toFixed(4)}`;
47 }
48
49 return usdSubCentCurrencyFormatter.format(dollars);
50 }
51
52 return usdCurrencyFormatter.format(microsToDollars(microsValue));
53}

Callers 8

currency.test.tsFile · 0.90
UserRowFunction · 0.90
PRInsightsViewFunction · 0.90
UsageIndicatorFunction · 0.90
ChatCostSummaryViewFunction · 0.90
UserOverridesSectionFunction · 0.90
GroupLimitsSectionFunction · 0.90
formatUsageLimitMessageFunction · 0.90

Calls 2

NumberFunction · 0.85
microsToDollarsFunction · 0.85

Tested by

no test coverage detected