Skip to content

Instantly share code, notes, and snippets.

@simoncpu
Created December 16, 2009 07:13
Show Gist options
  • Save simoncpu/257659 to your computer and use it in GitHub Desktop.
Save simoncpu/257659 to your computer and use it in GitHub Desktop.
getBytes : function (bytes, type) {
var value = bytes;
if (!isNaN(value)) {
switch (type) {
case 'Kb':
value *= 1024;
break;
case 'Mb':
value *= Math.pow(1024, 2);
break;
case 'Gb':
value *= Math.pow(1024, 3);
break;
default:
break;
}
return value;
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment