Last active
April 15, 2022 07:32
-
-
Save Shaxadhere/830aa444fd2287e7dacbca94296140b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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