Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
/ pretty_bytes Public archive

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

License

Notifications You must be signed in to change notification settings

kt3k/pretty_bytes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

This module is now merged to Deno's standard modules.

Use https://deno.land/std/fmt/bytes.ts instead.

pretty_bytes v2.0.0

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@v2.0.0/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