8bits
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);
byte(1000);
byte(1024, {digits: 2});
byte(1024, {digits: 2, binary: true});
byte(500000, {from: 'kB', to: 'MB'});
byte(512000, {from: 'kB', to: 'MB', binary: true});
Todo
- Retrieve byte value from human-readable value (i.e. 1 MB => 1048576)
- Improve Readme
License
MIT © Andrew Kennedy