Last active
August 29, 2015 14:18
-
-
Save sl0ki/1bb1486fc4e5207757ad to your computer and use it in GitHub Desktop.
JS LocalStorage Wrapper
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
/* | |
* Local Storage wrapper | |
*/ | |
var LStore = { | |
set: function(key, value) { | |
var rec = { | |
value: value, | |
updated: new Date().getTime() | |
}; | |
return localStorage.setItem(key, JSON.stringify(rec)); | |
}, | |
get: function(key) { | |
var rec = JSON.parse(localStorage.getItem(key)); | |
return rec ? rec.value : undefined; | |
}, | |
remove: function(key) { | |
return localStorage.removeItem(key); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment