MCPcopy Create free account
hub / github.com/astercloud/aster / formatCurrency

Function formatCurrency

studio/src/lib/utils.ts:21–32  ·  view source on GitHub ↗
(amount: number, currency: string = 'USD')

Source from the content-addressed store, hash-verified

19
20// Format currency
21export function formatCurrency(amount: number, currency: string = 'USD'): string {
22 if (currency === 'USD') {
23 if (amount < 0.01) {
24 return `$${(amount * 100).toFixed(2)}¢`;
25 }
26 return `$${amount.toFixed(4)}`;
27 }
28 if (currency === 'CNY') {
29 return `¥${amount.toFixed(2)}`;
30 }
31 return `${amount.toFixed(4)} ${currency}`;
32}
33
34// Format duration in milliseconds
35export function formatDuration(ms: number): string {

Callers 3

MetricsFunction · 0.90
OverviewFunction · 0.90
TraceDetailFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected