Socket
Socket
Sign inDemoInstall

superbytes

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    superbytes

Convert bytes to a human readable string format


Version published
Weekly downloads
544
decreased by-10.97%
Maintainers
1
Install size
42.4 kB
Created
Weekly downloads
 

Readme

Source

Superbytes

Superbytes is a Node.js library for converting bytes to human readable string format


npm npm NPM GitHub Workflow Status (with event) GitHub contributors

Description

Superbytes will help you convert bytes into other units understandable for humans. The library automatically converts bytes and returns a string with the most optimal unit representation. The library also allows you to set the precision of numbers following the decimal point and choose the output metric in the form of either the IEC standard (1024 bytes = 1 kibibyte) or SI (1000 bytes = 1 kilobyte).

By default superbytes converts to IEC units.

The current version supports loading library using both CommonJS and ESModules.

Installation

Latest version:

npm i superbytes@latest

Usage

Loading using CommonJS

const { superbytes } = require('superbytes');

superbytes(423551030);
// returns '403.93 MiB'
superbytes(423551030, 3);
// returns '403.930 MiB'
superbytes(72355103011, { metric: 'si'});
// returns '72.36 GB'
superbytes(3123123, { precision: 5});
// returns '2.97844 MiB'
superbytes(912839123, { metric: 'si', precision: 5});
// returns '912.83912 MB'

Loading using ES modules

import { superbytes } from 'superbytes';

superbytes(423551030);
// returns '403.93 MiB'
superbytes(423551030, 3);
// returns '403.930 MiB'
superbytes(72355103011, { metric: 'si'});
// returns '72.36 GB'
superbytes(3123123, { precision: 5});
// returns '2.97844 MiB'
superbytes(912839123, { metric: 'si', precision: 5});
// returns '912.83912 MB'

License

MIT © Damian Polak

FAQs

Last updated on 12 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc