mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Format long numbers. Updated README.
This commit is contained in:
parent
c6b9682296
commit
b1493dfef8
10 changed files with 77 additions and 26 deletions
|
|
@ -39,3 +39,23 @@ export function formatShortTime(val, formats = ['m', 's'], space = '') {
|
|||
|
||||
return t;
|
||||
}
|
||||
|
||||
export function formatNumber(n) {
|
||||
return Number(n).toFixed(0);
|
||||
}
|
||||
|
||||
export function formatLongNumber(n) {
|
||||
if (n >= 1000000) {
|
||||
return `${(n / 1000000).toFixed(1)}m`;
|
||||
}
|
||||
if (n >= 100000) {
|
||||
return `${(n / 1000).toFixed(0)}k`;
|
||||
}
|
||||
if (n >= 10000) {
|
||||
return `${(n / 1000).toFixed(1)}k`;
|
||||
}
|
||||
if (n >= 1000) {
|
||||
return `${(n / 1000).toFixed(2)}k`;
|
||||
}
|
||||
return formatNumber(n);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue