Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

byte-size

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byte-size

Convert a bytes or octets value (e.g. 34565346) to a human-readable string ('34.6 MB'). Choose between metric or IEC units.

  • 8.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is byte-size?

The byte-size npm package is a utility for converting bytes into human-readable format. It helps in formatting byte values into strings with appropriate units (e.g., KB, MB, GB) and provides options for customization.

What are byte-size's main functionalities?

Basic Conversion

This feature allows you to convert a byte value into a human-readable format. In this example, 1024 bytes are converted to 1 KB.

const byteSize = require('byte-size');
const result = byteSize(1024);
console.log(result); // { value: 1, unit: 'KB', long: '1 kilobyte' }

Custom Units

This feature allows you to specify custom units for the conversion. In this example, 1500 bytes are converted to 1.46 KiB using IEC units.

const byteSize = require('byte-size');
const result = byteSize(1500, { units: 'iec' });
console.log(result); // { value: 1.46, unit: 'KiB', long: '1.46 kibibytes' }

Decimal Places

This feature allows you to set the number of decimal places for the conversion. In this example, 123456789 bytes are converted to 117.74 MB with 2 decimal places.

const byteSize = require('byte-size');
const result = byteSize(123456789, { precision: 2 });
console.log(result); // { value: 117.74, unit: 'MB', long: '117.74 megabytes' }

Other packages similar to byte-size

Keywords

FAQs

Package last updated on 20 Jul 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc