formatBytes
Renders a byte count the way a file manager does, so a running total answers “is this getting huge?” at a glance.
Past the largest unit the number keeps growing rather than starting over, because under-reporting a size by a factor of 1024 is worse than an ungainly number.
Import:
import { formatBytes } from 'obsidian-dev-utils/bytes';Signature:
function formatBytes(bytes: number): stringParameters:
| Parameter | Type | Description |
|---|---|---|
bytes | number | The number of bytes. |
Returns: string — The formatted size, e.g. 1.4 MB.