Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

pretty_bytes v1.0.5

ci

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.

Usage

import { prettyBytes } from "https://deno.land/x/pretty_bytes@v1.0.5/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.

License

MIT