5 lines
293 B
TypeScript
5 lines
293 B
TypeScript
// Small formatters safe for the browser bundle (no Node modules).
|
|
|
|
/** «12 KB» — the size of a file for a person. */
|
|
export const humanSize = (n: number) => (n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${(n / 1024 / 1024).toFixed(1).replace(/\.0$/, "")} MB`);
|