21.6.15 • Published 4 months ago

bytes-formatter v21.6.15

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 months ago

Bytes Formatter Tweet

Build Status License NPM version NPM downloads

Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).

Usage

npm install bytes-formatter
# Or
yarn add bytes-formatter
import { formatBytes } from "bytes-formatter";

/**
 * Formats given <code>bytes</code> to human friendly format.
 * @param {number} bytes The bytes to be formatted.
 * @return {string} The formatted bytes as string.
 */
console.log(formatBytes(1000)); // "1000 bytes"
console.log(formatBytes(1024)); // "1.00 KB"
console.log(formatBytes(1000000)); // "976.56 KB"
console.log(formatBytes(2000000)); // "1.91 MB"
console.log(formatBytes(2000000000)); // "1.86 GB"
console.log(formatBytes(2000000000000)); // "1.82 TB"
console.log(formatBytes(Number.MAX_SAFE_INTEGER)); // "8.00 PB"
21.6.15

4 months ago

21.6.14

4 months ago

21.6.12

4 years ago

21.6.11

4 years ago

21.6.10

4 years ago

21.6.8

4 years ago

21.6.9

4 years ago

21.6.7

4 years ago

21.6.6

4 years ago

21.6.5

4 years ago

21.6.4

4 years ago

21.6.3

4 years ago

21.6.2

4 years ago

21.6.1

4 years ago

21.6.0

4 years ago