pretty-bytes
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The pretty-bytes npm package is designed to convert bytes into a human-readable string, making it particularly useful for displaying file sizes. By turning a raw number of bytes into a more understandable expression like '1.34 kB', pretty-bytes enables easier comprehension and handling of data-related metrics. It operates on base-10, otherwise known as the decimal system, which denotes the kilobyte (kB) measurement.
To use the pretty-bytes npm package, you will first need to install it using the command:
npm install pretty-bytes
Once installed, you can import the package into your JavaScript code as follows:
import prettyBytes from 'pretty-bytes';
Then, you can invoke the prettyBytes
function with the number of bytes you wish to convert. For example:
prettyBytes(1337); // Returns "1.34 kB"
prettyBytes(100); // Returns "100 B"
You can also use additional options to further customize the output:
prettyBytes(1337, {bits: true}); // Returns "1.34 kbit"
prettyBytes(42, {signed: true}); // Returns "+42 B"
prettyBytes(1337, {locale: 'de'}); // Returns "1,34 kB"
The pretty-bytes documentation resides within the project's GitHub page (git+https://github.com/sindresorhus/pretty-bytes.git) and includes everything you need to know about the usage, properties, and customization of the pretty-bytes package. From basic installation and usage instructions to detailed explanations of various options and settings, all vital information related to the pretty-bytes library is readily accessible in the GitHub repository README file.