This module is now merged to Deno's standard modules.
Use https://deno.land/std/fmt/bytes.ts instead.
Convert bytes to a human readable string: 1337 → 1.34 kB
A utility for displaying file sizes for humans.
Note: This module was ported from pretty-bytes.
import { prettyBytes } from "https://deno.land/x/[email protected]/mod.ts";
prettyBytes(1337);
//=> '1.34 kB'
prettyBytes(100);
//=> '100 B'
// Display with units of bits
prettyBytes(1337, { bits: true });
//=> '1.34 kbit'
// Display file size differences
prettyBytes(42, { signed: true });
//=> ' 42 B'
// Localized output using German locale
prettyBytes(1337, { locale: "de" });
//=> '1,34 kB'
See the API doc for more details.
MIT