15 lines
400 B
TypeScript
15 lines
400 B
TypeScript
export const formatBigNum = (num: number) => {
|
|
if (typeof num === "number") {
|
|
if (num >= 1000000000) {
|
|
return `${(num / 1000000000).toFixed(1).replace(/\.0$/, "")}B`;
|
|
}
|
|
if (num >= 1000000) {
|
|
return `${(num / 1000000).toFixed(1).replace(/\.0$/, "")}M`;
|
|
}
|
|
if (num >= 1000) {
|
|
return `${(num / 1000).toFixed(1).replace(/\.0$/, "")}K`;
|
|
}
|
|
return num;
|
|
}
|
|
};
|