Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 8, 2024 via pnpm

bytes 3.1.2

Utility to parse a string bytes to bytes and vice-versa
Package summary
Share
0
issues
1
license
1
MIT
Package created
11 Jun 2012
Version published
28 Jan 2022
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
bytes@3.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of bytes 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does bytes do?

Bytes is a highly versatile Node.js utility used for parsing a string of bytes into actual bytes and vice-versa. It is an excellent tool when you need to convert values like '1TB' into their byte equivalent (1099511627776), and also performs the inverse operation. This user-friendly utility plays a vital role in managing and converting digital storage units.

How do you use bytes?

You can make the most of Bytes by installing it through the npm registry, using the command npm install bytes. Once installed, you need to require bytes in your JavaScript file like so:

var bytes = require('bytes');

You now have access to the various functions bytes offers like bytes.format and bytes.parse.

For example, if you want to convert a number value to a string representation, you use:

bytes(1024);
// output: '1KB'

Or if you want to parse a string value into bytes:

bytes('1KB');
// output: 1024

The bytes.format function converts a numeric value in bytes into a string:

bytes.format(1024);
// output: '1KB'

You can further customize the output with different options for decimal places, thousands separators, and more.

bytes.format(1024, {unitSeparator: ' '});
// output: '1 KB'

The bytes.parse function does the opposite, it converts a string representation of a value into bytes:

bytes.parse('1KB');
// output: 1024

Please note that Bytes utility uses powers of two for conversion, staying consistent with digital storage conventions.

Where are the bytes docs?

The comprehensive documentation for Bytes can be found directly on its npm registry page (https://www.npmjs.com/package/bytes). It provides a detailed overview of the installation process, functions, parameters, return types, and real-life examples. Should you need a deeper understanding of different functions or versions, you can browse the GitHub documentation linked from the npm page (https://github.com/visionmedia/bytes.js.git).