mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-23 09:32:29 +01:00
7 lines
236 B
TypeScript
7 lines
236 B
TypeScript
export function bytesToHuman (bytes: number): string {
|
|
const i = Math.floor(Math.log(bytes) / Math.log(1000));
|
|
|
|
// @ts-ignore
|
|
return `${(bytes / Math.pow(1000, i)).toFixed(2) * 1} ${['Bytes', 'kB', 'MB', 'GB', 'TB'][i]}`;
|
|
}
|