mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
492 B
29 lines
492 B
this.LocalStorageStore = class LocalStorageStore {
|
|
get(key) {
|
|
try {
|
|
return JSON.parse(localStorage.getItem(key));
|
|
} catch (error) {}
|
|
}
|
|
|
|
set(key, value) {
|
|
try {
|
|
localStorage.setItem(key, JSON.stringify(value));
|
|
return true;
|
|
} catch (error) {}
|
|
}
|
|
|
|
del(key) {
|
|
try {
|
|
localStorage.removeItem(key);
|
|
return true;
|
|
} catch (error) {}
|
|
}
|
|
|
|
reset() {
|
|
try {
|
|
localStorage.clear();
|
|
return true;
|
|
} catch (error) {}
|
|
}
|
|
};
|