gradio / js /file /shared /utils.ts
mindmime's picture
Upload folder using huggingface_hub
a03b3ba verified
raw
history blame contribute delete
No virus
281 Bytes
import type { FileData } from "@gradio/client";
export const prettyBytes = (bytes: number): string => {
let units = ["B", "KB", "MB", "GB", "PB"];
let i = 0;
while (bytes > 1024) {
bytes /= 1024;
i++;
}
let unit = units[i];
return bytes.toFixed(1) + " " + unit;
};