gradio/js/file/shared/utils.ts
Yuichiro Tachibana (Tsuchiya) f94db6b731
File table style with accessible file name texts (#6520)
* File table style with accessible file name texts

* Fix for lint

* add changeset

* Remove unnecessary style

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2023-11-22 00:46:37 +09:00

13 lines
281 B
TypeScript

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) + "&nbsp;" + unit;
};