Socket
Socket
Sign inDemoInstall

8bits

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

8bits

A Javascript library for manipulating and converting byte values


Version published
Weekly downloads
4
decreased by-76.47%
Maintainers
1
Weekly downloads
 
Created
Source

8bits Build Status

A Javascript library for manipulating and converting byte values

There are two primary ways to represent byte sizes: SI units (decimal / base-10 / 10^3) and IEC units (binary; / base 2 / 2^10). 8bits supports both of formats, with the default being decimal. You can read more on this subject here and here.

Install

$ npm install --save 8bits

Usage

var byte = require('8bits');

byte(789);
//=> 789 B

byte(1000);
//=> 1 kB

// Setting the number of significant digits
byte(1024, {digits: 2});
//=> 1.02 kB

// Using binary instead of decimal
byte(1024, {digits: 2, binary: true});
//=> 1.00 KB

// Converting from one prefix to another
byte(500000, {from: 'kB', to: 'MB'});
//=> 500 MB
byte(512000, {from: 'kB', to: 'MB', binary: true});
//=> 500 MB

Todo

  • Retrieve byte value from human-readable value (i.e. 1 MB => 1048576)
  • Improve Readme

License

MIT © Andrew Kennedy

Keywords

FAQs

Package last updated on 19 Feb 2015

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