(count: number)
| 271 | * - >=1000000: M suffix with 1 decimal (e.g., "1.2M") |
| 272 | */ |
| 273 | export function formatInstallCount(count: number): string { |
| 274 | if (count < 1000) { |
| 275 | return String(count) |
| 276 | } |
| 277 | |
| 278 | if (count < 1000000) { |
| 279 | const k = count / 1000 |
| 280 | // Use toFixed(1) but remove trailing .0 |
| 281 | const formatted = k.toFixed(1) |
| 282 | return formatted.endsWith('.0') |
| 283 | ? `${formatted.slice(0, -2)}K` |
| 284 | : `${formatted}K` |
| 285 | } |
| 286 | |
| 287 | const m = count / 1000000 |
| 288 | const formatted = m.toFixed(1) |
| 289 | return formatted.endsWith('.0') |
| 290 | ? `${formatted.slice(0, -2)}M` |
| 291 | : `${formatted}M` |
| 292 | } |
| 293 |
no outgoing calls
no test coverage detected