Skip to content

Instantly share code, notes, and snippets.

@gladkih
Created July 27, 2015 11:24
Show Gist options
  • Save gladkih/865a311c0f77f657ca05 to your computer and use it in GitHub Desktop.
Save gladkih/865a311c0f77f657ca05 to your computer and use it in GitHub Desktop.
function gen(n) {
return new Array((n * 1024) + 1).join('a')
}
if (!localStorage.getItem('size')) {
var i = 0;
try {
// Test up to 10 MB
for (i = 0; i <= 10000; i += 250) {
localStorage.setItem('test', gen(i));
}
} catch (e) {
localStorage.removeItem('test');
localStorage.setItem('size', i ? i - 250 : 0);
}
}
console.log(localStorage.getItem('size'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment