mirror of
https://github.com/jnsahaj/tweakcn.git
synced 2026-09-01 15:37:45 +08:00
10 lines
238 B
TypeScript
10 lines
238 B
TypeScript
/**
|
|
* Format number to show in k format (e.g., 1557 => 1.6k)
|
|
*/
|
|
export function formatCompactNumber(num: number): string {
|
|
if (num < 1000) {
|
|
return num.toString();
|
|
}
|
|
return (num / 1000).toFixed(1).replace(/\.0$/, "") + "k";
|
|
}
|