ars-formatbytes
is a lightweight, simple-to-use JavaScript library for converting byte values into human-readable formats. It supports formats from Bytes to Yottabytes.
Install ars-formatbytes
using npm:
npm install ars-formatbytes
Here's a quick example to get you started:
const formatBytes = require('ars-formatbytes');
const fileSize = formatBytes(15360); // 15 KB
console.log(fileSize);
const largeFileSize = formatBytes(1073741824); // 1 GB
console.log(largeFileSize);
formatBytes
function accepts two arguments:
-
bytes
(required): The size in bytes. -
decimals
(optional): Number of decimal places to format the output. Default is 2.
- Easy-to-use: Simple API with only two parameters.
- Lightweight with no dependencies.
- Covers a wide range of sizes from Bytes to Yottabytes.
Contributions are welcome, and any feedback or suggestions are greatly appreciated!
This project is licensed under the MIT License.