File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
apps/web-roo-code/src/lib Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,19 @@ export async function getVSCodeDownloads() {
104104}
105105
106106function formatNumber ( num : number ) : string {
107- // divide by 1000 to convert to "thousands" format,
108- // multiply by 10, floor the result, then divide by 10 to keep one decimal place.
107+ // if number is 1 million or more, format as millions
108+ if ( num >= 1000000 ) {
109+ const truncated = Math . floor ( ( num / 1000000 ) * 10 ) / 10
110+ return truncated . toFixed ( 1 ) + "M"
111+ }
112+
113+ // otherwise, format as thousands
109114 const truncated = Math . floor ( ( num / 1000 ) * 10 ) / 10
110- // ensure one decimal is always shown and append "k"
111115 return truncated . toFixed ( 1 ) + "k"
112116
113117 // examples:
118+ // console.log(formatNumber(1033400)) -> "1.0M"
119+ // console.log(formatNumber(2500000)) -> "2.5M"
114120 // console.log(formatNumber(337231)) -> "337.2k"
115121 // console.log(formatNumber(23233)) -> "23.2k"
116122 // console.log(formatNumber(2322)) -> "2.3k"
You can’t perform that action at this time.
0 commit comments