Skip to content

Instantly share code, notes, and snippets.

@nesvand
Forked from levigideon/localstorage.dump.js
Last active April 16, 2018 23:33
Show Gist options
  • Save nesvand/f4f0aaa883b529aa7d614e2e98e167d7 to your computer and use it in GitHub Desktop.
Save nesvand/f4f0aaa883b529aa7d614e2e98e167d7 to your computer and use it in GitHub Desktop.
Storage dump
Storage.prototype.dump = function () {
let dump = {};
for (const key in this) {
if (this.hasOwnProperty(key)) {
try {
dump[key] = JSON.parse(this.getItem(key));
} catch (e) {
dump[key] = this.getItem(key);
}
}
}
return dump;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment