Created
May 28, 2015 10:14
-
-
Save jasdeepkhalsa/b49da60291b91b548310 to your computer and use it in GitHub Desktop.
HTML5 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
var store = { | |
name: 'default_key_name', | |
get: function(_key) { | |
var key = _key || this.name; | |
return JSON.parse(localStorage.getItem(key) || '[]'); | |
}, | |
set: function(value, _key) { | |
var key = _key || this.name; | |
localStorage.setItem(key, JSON.stringify(value)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment