Comparing version 1.0.0 to 1.1.0
15
index.js
@@ -11,3 +11,18 @@ (function (global, factory) { | ||
function siz(size) { | ||
var num = parseInt(size); | ||
if (/[0-9]*k(b|B)?/ig.test(size)) { | ||
return num * 1024; | ||
} | ||
if (/[0-9]*m(b|B)?/ig.test(size)) { | ||
return num * 1024 * 1024; | ||
} | ||
if (/[0-9]*g(b|B)?/ig.test(size)) { | ||
return num * 1024 * 1024 * 1024; | ||
} | ||
if (/[0-9]*t(b|B)?/ig.test(size)) { | ||
return num * 1024 * 1024 * 1024 * 1024; | ||
} | ||
} | ||
@@ -14,0 +29,0 @@ |
@@ -10,5 +10,5 @@ { | ||
"main": "index.js", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"devDependencies": {}, | ||
"license": "MIT" | ||
} |
@@ -1,3 +0,36 @@ | ||
## siz | ||
## about siz | ||
This is a simple file unit conversion function with only a few lines of code. Ok, it’s that simple, you can say that it’s useless. | ||
This is a simple file unit conversion function with only a few lines of code. Ok, it’s that simple, you can say that it’s useless. | ||
## useage | ||
``` | ||
import siz from 'siz'; | ||
siz('100kb'); | ||
102400 | ||
siz('100KB'); | ||
102400 | ||
siz('100K'); | ||
102400 | ||
siz('100k'); | ||
102400 | ||
siz('100mb'); | ||
104857600 | ||
siz('100m'); | ||
104857600 | ||
siz('1m'); | ||
1048576 | ||
siz('1gb'); | ||
1073741824 | ||
siz('1t'); | ||
1099511627776 | ||
``` |
1407
26
36