MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / fmtNum

Function fmtNum

ui/src/components/PushApprovalPanel.tsx:63–72  ·  view source on GitHub ↗
(n: number | string | undefined | null)

Source from the content-addressed store, hash-verified

61}
62
63function fmtNum(n: number | string | undefined | null): string {
64 if (n == null || n === '') return ''
65 if (isUnsetDecimal(n)) return ''
66 if (typeof n === 'string') return n
67 if (!Number.isFinite(n)) return String(n)
68 const rounded = n.toFixed(8).replace(/\.?0+$/, '')
69 const [intPart, decPart] = rounded.split('.')
70 const withCommas = Number(intPart).toLocaleString(getIntlLocale())
71 return decPart ? `${withCommas}.${decPart}` : withCommas
72}
73
74function orderTypeLabel(type: string | undefined): string {
75 const raw = (type || '').toUpperCase()

Callers 1

operationDisplayFunction · 0.70

Calls 2

isUnsetDecimalFunction · 0.90
getIntlLocaleFunction · 0.90

Tested by

no test coverage detected