-
-
Save imlinus/e12878284d401c612f20ed6225673198 to your computer and use it in GitHub Desktop.
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
Ls.remove('foo').then(function () { | |
Ls.set('foo', 'bar'); | |
}); | |
console.log( Ls.get('foo') ) |
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 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