Last active
September 20, 2019 21:02
-
-
Save pseudosavant/bfe8bba4302f465f5f21e038caae228a to your computer and use it in GitHub Desktop.
Easy way to determine currently used space in localStorage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const totalSize = Object.values(localStorage).reduce((acc, c) => acc += c.length, 0); | |
const length = Object.values(localStorage).length; | |
console.log(`${length} entries using ${totalSize} bytes (${Math.floor(totalSize/length)} bytes/entry)`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment