Skip to content

Instantly share code, notes, and snippets.

@Shaxadhere
Last active April 15, 2022 07:32
Show Gist options
  • Save Shaxadhere/830aa444fd2287e7dacbca94296140b3 to your computer and use it in GitHub Desktop.
Save Shaxadhere/830aa444fd2287e7dacbca94296140b3 to your computer and use it in GitHub Desktop.
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);
});
}
};
////OR/////
//with newer syntax
const asyncLocalStorage = {
setItem: async function (key, value) {
await null;
return localStorage.setItem(key, value);
},
getItem: async function (key) {
await null;
return localStorage.getItem(key);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment