mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-09-07 09:13:00 +02:00
Introduce units.js, centralizes value normalizing
This commit is contained in:
@@ -123,22 +123,6 @@ export function init(extraInitQuery = "") {
|
||||
};
|
||||
}
|
||||
|
||||
export function formatNumber(x) {
|
||||
let suffix = "";
|
||||
if (x >= 1000000000) {
|
||||
x /= 1000000;
|
||||
suffix = "G";
|
||||
} else if (x >= 1000000) {
|
||||
x /= 1000000;
|
||||
suffix = "M";
|
||||
} else if (x >= 1000) {
|
||||
x /= 1000;
|
||||
suffix = "k";
|
||||
}
|
||||
|
||||
return `${Math.round(x * 100) / 100} ${suffix}`;
|
||||
}
|
||||
|
||||
// Use https://developer.mozilla.org/en-US/docs/Web/API/structuredClone instead?
|
||||
export function deepCopy(x) {
|
||||
return JSON.parse(JSON.stringify(x));
|
||||
|
Reference in New Issue
Block a user