First upload version 0.0.1
This commit is contained in:
18
node_modules/lowdb/lib/adapters/browser/WebStorage.js
generated
vendored
Normal file
18
node_modules/lowdb/lib/adapters/browser/WebStorage.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export class WebStorage {
|
||||
#key;
|
||||
#storage;
|
||||
constructor(key, storage) {
|
||||
this.#key = key;
|
||||
this.#storage = storage;
|
||||
}
|
||||
read() {
|
||||
const value = this.#storage.getItem(this.#key);
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(value);
|
||||
}
|
||||
write(obj) {
|
||||
this.#storage.setItem(this.#key, JSON.stringify(obj));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user