3688196859
Strings:getBytesFromShorthand i created a js-function which converts integer, k, m and g to MB Just remove this code, when we found out, why Strings is in some files not working.
24 lines
400 B
JavaScript
24 lines
400 B
JavaScript
function isInteger(value) {
|
|
return /^\d+$/.test(value);
|
|
}
|
|
|
|
function getMBytes(value) {
|
|
var res;
|
|
if (isInteger(value)) {
|
|
res = value;
|
|
} else {
|
|
eh = value.slice(-1);
|
|
am = Number(value.slice(0, -1));
|
|
switch (eh) {
|
|
case 'k':
|
|
res = am * 1024;
|
|
break;
|
|
case 'm':
|
|
res = am * 1024 * 1024;
|
|
break;
|
|
case 'g':
|
|
res = am * 1024 * 1024 * 1024;
|
|
}
|
|
}
|
|
return res / 1000000;
|
|
}
|