Created
October 7, 2024 13:45
-
-
Save shuantsu/2530ab95c9eb2223a0098f469673974c to your computer and use it in GitHub Desktop.
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
// 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