mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add dashboard
This commit is contained in:
14
dashboard/utils/prettyNumber.ts
Normal file
14
dashboard/utils/prettyNumber.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
export function prettyNumber000(value: number | string) {
|
||||
return Math.floor(parseInt(value.toString())).toLocaleString('en-EN').replace(/,/g, '.');
|
||||
}
|
||||
|
||||
export function formatNumberK(value: string | number, decimals: number = 1) {
|
||||
const num = parseInt(value.toString());
|
||||
|
||||
if (num > 1_000_000) return (num / 1_000_000).toFixed(decimals) + ' M';
|
||||
if (num > 1_000) return (num / 1_000).toFixed(decimals) + ' K';
|
||||
return num.toFixed();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user