@ende/fmt/bytes

ende add jsr:@ende/fmt

Version 2026.10.15 on JSR.

Convert bytes to a human-readable string: 1337 → 1.34 kB

Based on pretty-bytes. A utility for displaying file sizes for humans.

import { format } from "@ende/fmt/bytes";
import { assertEquals } from "@ende/assert";

assertEquals(format(1337), "1.34 kB");
assertEquals(format(100), "100 B");

Exports

  • format — Convert bytes to a human-readable string: 1337 → 1.34 kB
  • FormatOptions — Options for format.