Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created August 8, 2011 13:20
Show Gist options
  • Save pinscript/1131725 to your computer and use it in GitHub Desktop.
Save pinscript/1131725 to your computer and use it in GitHub Desktop.
function Storage() {
this.isSupported = function () {
try {
return !!localStorage.getItem;
} catch (e) {
return false;
}
};
this.get = function (name) {
return JSON.parse(window.localStorage.getItem(name));
};
this.set = function (name, value) {
window.localStorage.setItem(name, JSON.stringify(value));
};
this.clear = function () {
window.localStorage.clear();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment