https://github.com/hustcc/byte-parser
:eight: (130B) Parse byte string to byte number, e.g. 1.2 Kb -> 1228.8, Kb, Mb, Gb, Tb, Pb, Eb, Zb, Yb supported.
https://github.com/hustcc/byte-parser
byte byte-number byte-parser
Last synced: about 1 month ago
JSON representation
:eight: (130B) Parse byte string to byte number, e.g. 1.2 Kb -> 1228.8, Kb, Mb, Gb, Tb, Pb, Eb, Zb, Yb supported.
- Host: GitHub
- URL: https://github.com/hustcc/byte-parser
- Owner: hustcc
- License: mit
- Created: 2020-09-15T12:54:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-15T12:55:20.000Z (over 4 years ago)
- Last Synced: 2025-03-17T07:51:27.442Z (about 1 month ago)
- Topics: byte, byte-number, byte-parser
- Language: TypeScript
- Homepage:
- Size: 2.93 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
[](https://www.npmjs.com/package/byte-parser)
[](https://github.com/hustcc/byte-parser/actions)
[](https://www.npmjs.com/package/byte-parser)
[](https://www.npmjs.com/package/byte-parser)## Install
```bash
$ npm i --save-dev byte-parser
```## Usage
```ts
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](https://github.com/hustcc).