reorganize code into smaller files & dirs
This commit is contained in:
16
packages/app/src/Utils/Number.ts
Normal file
16
packages/app/src/Utils/Number.ts
Normal file
@ -0,0 +1,16 @@
|
||||
const intl = new Intl.NumberFormat("en", {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
|
||||
export function formatShort(n: number) {
|
||||
if (n < 2e3) {
|
||||
return n;
|
||||
} else if (n < 1e6) {
|
||||
return `${intl.format(n / 1e3)}K`;
|
||||
} else if (n < 1e9) {
|
||||
return `${intl.format(n / 1e6)}M`;
|
||||
} else {
|
||||
return `${intl.format(n / 1e9)}G`;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user