🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

prettysize

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettysize

Convert bytes to other sizes for prettier logging

2.0.0
latest
Source
npm
Version published
Weekly downloads
209K
-3.22%
Maintainers
1
Weekly downloads
 
Created

What is prettysize?

The prettysize npm package is a utility for converting file sizes into human-readable strings. It simplifies the process of displaying file sizes in a more understandable format, such as converting bytes into kilobytes, megabytes, etc.

What are prettysize's main functionalities?

Basic Usage

This feature allows you to convert a file size in bytes to a human-readable string. In this example, 123456789 bytes is converted to '117.7 MB'.

const prettysize = require('prettysize');
console.log(prettysize(123456789)); // '117.7 MB'

Customizing Units

This feature allows you to customize the units used in the conversion. By passing `true` as the second argument, the output uses binary units (MiB) instead of decimal units (MB).

const prettysize = require('prettysize');
console.log(prettysize(123456789, true)); // '117.7 MiB'

Specifying Number of Decimal Places

This feature allows you to specify the number of decimal places in the output. In this example, the output is formatted to two decimal places.

const prettysize = require('prettysize');
console.log(prettysize(123456789, {places: 2})); // '117.74 MB'

Other packages similar to prettysize

Keywords

size

FAQs

Package last updated on 07 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts