MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getNumberFormatter

Function getNumberFormatter

src/utils/format.ts:100–122  ·  view source on GitHub ↗
(
  useConsistentDecimals: boolean,
)

Source from the content-addressed store, hash-verified

98let numberFormatterForConsistentDecimals: Intl.NumberFormat | null = null
99let numberFormatterForInconsistentDecimals: Intl.NumberFormat | null = null
100const getNumberFormatter = (
101 useConsistentDecimals: boolean,
102): Intl.NumberFormat => {
103 if (useConsistentDecimals) {
104 if (!numberFormatterForConsistentDecimals) {
105 numberFormatterForConsistentDecimals = new Intl.NumberFormat('en-US', {
106 notation: 'compact',
107 maximumFractionDigits: 1,
108 minimumFractionDigits: 1,
109 })
110 }
111 return numberFormatterForConsistentDecimals
112 } else {
113 if (!numberFormatterForInconsistentDecimals) {
114 numberFormatterForInconsistentDecimals = new Intl.NumberFormat('en-US', {
115 notation: 'compact',
116 maximumFractionDigits: 1,
117 minimumFractionDigits: 0,
118 })
119 }
120 return numberFormatterForInconsistentDecimals
121 }
122}
123
124export function formatNumber(number: number): string {
125 // Only use minimumFractionDigits for numbers that will be shown in compact notation

Callers 1

formatNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected