byte-parser
v1.0.0
Published
Parse byte string to byte number, e.g. 1.2 Kb -> 1228.8, Kb, Mb, Gb, Tb, Pb, Eb, Zb, Yb supported.
Downloads
941
Maintainers
Readme
byte-parser
Parse byte string to byte number, e.g.
1.2 Kb
->1228.8
, Kb, Mb, Gb, Tb, Pb, Eb, Zb, Yb supported.
Install
$ npm i --save-dev byte-parser
Usage
import parse from 'byte-parser';
parse('100'); // 100
parse('10.1 b'); // 10.1
parse('10.1 KB'); // 10.1 * 1024
parse('10.1 kb', 1000); // 10.1 * 1000
parse('1.2 mb'); // 1.2 * 1024 * 1024
parse('1.2 Gb'); // 1.2 * 1024 * 1024 * 1024
parse('1.2 G'); // 1.2 * 1024 * 1024 * 1024
License
MIT@hustcc.