Skip to content

Instantly share code, notes, and snippets.

@sl0ki
Last active August 29, 2015 14:18
Show Gist options
  • Save sl0ki/1bb1486fc4e5207757ad to your computer and use it in GitHub Desktop.
Save sl0ki/1bb1486fc4e5207757ad to your computer and use it in GitHub Desktop.
JS LocalStorage Wrapper
/*
* 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