Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@imlinus
Created March 12, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imlinus/e12878284d401c612f20ed6225673198 to your computer and use it in GitHub Desktop.
Save imlinus/e12878284d401c612f20ed6225673198 to your computer and use it in GitHub Desktop.
LocalStorage wrapper
Ls.remove('foo').then(function () {
Ls.set('foo', 'bar');
});
console.log( Ls.get('foo') )
var Ls = {
cb: '',
get: function (key) {
return localStorage.getItem(key);
},
set: function (key, val) {
localStorage.setItem(key, val);
return this;
},
remove: function (key) {
localStorage.removeItem(key);
return this;
},
then: function(cb) {
cb();
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment