Created
December 19, 2016 13:51
-
-
Save ironboy/a86892bdac2acb1659c224a54b4c9e8c to your computer and use it in GitHub Desktop.
Small localStorage wrapper
This file contains 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
function lStore(key,val){ | |
var parsed = JSON.parse(localStorage.store || '{}'); | |
if(val === undefined){ | |
// read | |
return parsed[key]; | |
} | |
// write | |
parsed[key] = val; | |
localStorage.store = JSON.stringify(parsed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment