aboutsummaryrefslogtreecommitdiff
path: root/src/util/bytes.ts
blob: 43ad49c2b7ac9687be41ca17b26a87a45037a2ae (plain)
1
2
3
4
5
export const formatBytes = (n: number): string => {
  if (n >= 1_048_576) return `${(n / 1_048_576).toFixed(1)} MB`;
  if (n >= 1024) return `${(n / 1024).toFixed(1)} KB`;
  return `${n} B`;
};