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
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| byteSize | 7 to 11 | 3 | 100% | OkCRAP 3 | No 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`;
}