Skip to content

Instantly share code, notes, and snippets.

@rbk
Created August 28, 2022 12:34
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 rbk/0c058f6383977f53cc2d3f41d3cdc335 to your computer and use it in GitHub Desktop.
Save rbk/0c058f6383977f53cc2d3f41d3cdc335 to your computer and use it in GitHub Desktop.
Simple async localStorage.
const asyncLocalStorage = {
setItem: function (key, value) {
return Promise.resolve().then(function () {
localStorage.setItem(key, value);
});
},
getItem: function (key) {
return Promise.resolve().then(function () {
return localStorage.getItem(key);
});
},
removeItem: function (key) {
return Promise.resolve().then(function () {
return localStorage.removeItem(key);
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment