mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: display install count in millions instead of thousands (#9677)
Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
parent
127ecf6ddd
commit
c688a6466e
1 changed files with 9 additions and 3 deletions
|
|
@ -104,13 +104,19 @@ export async function getVSCodeDownloads() {
|
|||
}
|
||||
|
||||
function formatNumber(num: number): string {
|
||||
// divide by 1000 to convert to "thousands" format,
|
||||
// multiply by 10, floor the result, then divide by 10 to keep one decimal place.
|
||||
// if number is 1 million or more, format as millions
|
||||
if (num >= 1000000) {
|
||||
const truncated = Math.floor((num / 1000000) * 10) / 10
|
||||
return truncated.toFixed(1) + "M"
|
||||
}
|
||||
|
||||
// otherwise, format as thousands
|
||||
const truncated = Math.floor((num / 1000) * 10) / 10
|
||||
// ensure one decimal is always shown and append "k"
|
||||
return truncated.toFixed(1) + "k"
|
||||
|
||||
// examples:
|
||||
// console.log(formatNumber(1033400)) -> "1.0M"
|
||||
// console.log(formatNumber(2500000)) -> "2.5M"
|
||||
// console.log(formatNumber(337231)) -> "337.2k"
|
||||
// console.log(formatNumber(23233)) -> "23.2k"
|
||||
// console.log(formatNumber(2322)) -> "2.3k"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue