Created
July 10, 2022 23:23
-
-
Save pfftdammitchris/a88aff74ef9323a15c3259abf69a95c1 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
class LocalStorage { | |
#data = {} | |
static _instance = null | |
static getInstance(options) { | |
if (!LocalStorage._instance) { | |
LocalStorage._instance = new LocalStorage(options) | |
} | |
return LocalStorage._instance | |
} | |
constructor(options) { | |
this.options = options || {} | |
} | |
get(key) { | |
return this.#data[key] | |
} | |
set(key, value) { | |
this.#data[key] = value | |
} | |
remove(key) { | |
delete this.#data[key] | |
} | |
clear() { | |
this.#data = {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment