fix: fixing tsc errors

This commit is contained in:
Hydra 2024-05-12 13:29:12 +01:00
parent 13743cd7a5
commit c29f28dbdd
No known key found for this signature in database
22 changed files with 79 additions and 100 deletions

View file

@ -14,6 +14,22 @@ export enum Downloader {
Torrent,
}
const FORMAT = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
export const formatBytes = (bytes: number): string => {
if (!Number.isFinite(bytes) || isNaN(bytes) || bytes <= 0) {
return `0 ${FORMAT[0]}`;
}
const byteKBase = 1024;
const base = Math.floor(Math.log(bytes) / Math.log(byteKBase));
const formatedByte = bytes / byteKBase ** base;
return `${Math.trunc(formatedByte * 10) / 10} ${FORMAT[base]}`;
};
export class GameStatusHelper {
public static isDownloading(status: GameStatus | null) {
return (