randydev commited on
Commit
48e0731
·
verified ·
1 Parent(s): a06fd3a

Create util.js

Browse files
Files changed (1) hide show
  1. lib/sfilemobi/util.js +16 -0
lib/sfilemobi/util.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export function parseFileSize(size) {
2
+ const sized = parseFloat(size);
3
+ return (isNaN(sized) ? 0 : sized) * (
4
+ /GB/i.test(size)
5
+ ? 1000000
6
+ : /MB/i.test(size)
7
+ ? 1000
8
+ : /KB/i.test(size)
9
+ ? 1
10
+ : /bytes?/i.test(size)
11
+ ? 0.001
12
+ : /B/i.test(size)
13
+ ? 0.1
14
+ : 0
15
+ );
16
+ }