Skip to content

Instantly share code, notes, and snippets.

@pierr
Last active November 2, 2017 11:33
Show Gist options
  • Save pierr/2c11cdd1f57d3a4276fa to your computer and use it in GitHub Desktop.
Save pierr/2c11cdd1f57d3a4276fa to your computer and use it in GitHub Desktop.
localstorageSize.js
/* Process the occupied size in the local storage.
* @return {localstorageSize} [description]
*/
function processLocalStorageSize() {
var total = 0;
for (var x in localStorage) {
total += (localStorage[x].length * 2) / 1024 / 1024;
//console.log(x + " = " + amount.toFixed(2) + " MB");
}
return total.toFixed(2) + " MB";
}
console.log(processLocalStorageSize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment