mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
24 lines
612 B
JavaScript
24 lines
612 B
JavaScript
import moment from 'moment';
|
|
|
|
const BYTES_PER_GIGABYTE = 1000000000;
|
|
const NANOSECONDS_PER_MILLISECOND = 1000000;
|
|
|
|
const inGigaBytes = (bytes) => {
|
|
return (bytes / BYTES_PER_GIGABYTE).toFixed(2);
|
|
};
|
|
|
|
const inMilliseconds = (nanoseconds) => {
|
|
return nanoseconds / NANOSECONDS_PER_MILLISECOND;
|
|
};
|
|
|
|
export const humanUptime = (uptimeInNanoseconds) => {
|
|
const milliseconds = inMilliseconds(uptimeInNanoseconds);
|
|
|
|
return moment.duration(milliseconds, 'milliseconds').humanize();
|
|
};
|
|
|
|
export const humanMemory = (bytes) => {
|
|
return `${inGigaBytes(bytes)} GB`;
|
|
};
|
|
|
|
export default { humanMemory, humanUptime };
|