Skip to the content

Capsid menu

app/lib/media/byte-size.mjs

11 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of byte-size.mjs
FunctionLinesComplexityCoveredCRAPMutation
byteSize7 to 113100%OkCRAP 3No data: no mutants in this code

Imports

It imports no other module of this repo. Imported by app/components/admin/media-bulk-bar.tsx, app/components/admin/media-inspector-sections.tsx, app/components/admin/media-palette.tsx, app/components/admin/media-tile.tsx, app/lib/media/upload-contract.mjs.

Source

/**
 * Decimal unit names but BINARY division, deliberately: changing it restates every size on the media page.
 *
 * @param {number} size
 * @returns {string}
 */
export function byteSize(size) {
  if (size < 1024) return `${size} B`;
  if (size < 1024 * 1024) return `${Math.round(size / 1024)} kB`;
  return `${(size / (1024 * 1024)).toFixed(1)} MB`;
}