Unites
Fast utility for calculate SI and Binary unit prefixes (Units of information). ⚡️
Install
yarn add unites
npm install unites
UMD file is also available on unpkg:
You can use the library via window.unites
.
Usage
Metric prefix (SI)
Calculates the Metric prefix (SI) and returns the size.
si'1M'.kilos// 1000 si1, 'M'.kilos// 1000
Binary prefix
Calculates the Binary prefix and returns the size.
binary'1G'.megas// 1024 binary1, 'G'.megas// 1024
API
Unit prefixes
si value: number | string, symbol?: string: Unitsbinary value: number | string, symbol?: string: Units
Measurement units
si'1M'.bytes // numbersi'1M'.kilos // numbersi'1M'.megas // numbersi'1M'.gigas // numbersi'1M'.teras // numbersi'1M'.petas // numbersi'1M'.exas // numbersi'1M'.yottas // number
- Number values supported: Make sure that
symbol
param containsk
,M
,G
,T
,P
,E
,Z
orY
. - String values supported:
1k
,0.5M
,10G
,1T
,1.5P
,0E
,2Z
or0.0001Y
Contributions
Feel free to send some Pull request or issue.
License
MIT license
© 2018 José Luis Quintana