MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getNumberFormatter

Function getNumberFormatter

source code/utils/format.ts:102–124  ·  view source on GitHub ↗
(
  useConsistentDecimals: boolean,
)

Source from the content-addressed store, hash-verified

100let numberFormatterForConsistentDecimals: Intl.NumberFormat | null = null
101let numberFormatterForInconsistentDecimals: Intl.NumberFormat | null = null
102const getNumberFormatter = (
103 useConsistentDecimals: boolean,
104): Intl.NumberFormat => {
105 if (useConsistentDecimals) {
106 if (!numberFormatterForConsistentDecimals) {
107 numberFormatterForConsistentDecimals = new Intl.NumberFormat('en-US', {
108 notation: 'compact',
109 maximumFractionDigits: 1,
110 minimumFractionDigits: 1,
111 })
112 }
113 return numberFormatterForConsistentDecimals
114 } else {
115 if (!numberFormatterForInconsistentDecimals) {
116 numberFormatterForInconsistentDecimals = new Intl.NumberFormat('en-US', {
117 notation: 'compact',
118 maximumFractionDigits: 1,
119 minimumFractionDigits: 0,
120 })
121 }
122 return numberFormatterForInconsistentDecimals
123 }
124}
125
126export function formatNumber(number: number): string {
127 // 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