Skip to content

Instantly share code, notes, and snippets.

Jesus Guevara guevaraj31

Block or report user

Report or block guevaraj31

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lanqy / bytesToSize.js
Created Mar 19, 2013
JavaScript To Convert Bytes To MB, KB, Etc
View bytesToSize.js
// from
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
You can’t perform that action at this time.