Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfftdammitchris/a88aff74ef9323a15c3259abf69a95c1 to your computer and use it in GitHub Desktop.
Save pfftdammitchris/a88aff74ef9323a15c3259abf69a95c1 to your computer and use it in GitHub Desktop.
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