Skip to content

Instantly share code, notes, and snippets.

@shuantsu
Created October 7, 2024 13:45
Show Gist options
  • Save shuantsu/2530ab95c9eb2223a0098f469673974c to your computer and use it in GitHub Desktop.
Save shuantsu/2530ab95c9eb2223a0098f469673974c to your computer and use it in GitHub Desktop.
// Utility micro library "LocalStorj"
const LocalStorj = {
get: (key, defaultValue = null) => {
const result = localStorage.getItem(key)
if (result === null) {
return defaultValue;
}
return result;
},
set: (key, value) => {
localStorage.setItem(key, value);
},
flush: () => {
localStorage.clear();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment