mirror of
https://github.com/DevJSTAR/JSTAR-Tab.git
synced 2025-04-18 17:35:26 +00:00
36 lines
732 B
JavaScript
36 lines
732 B
JavaScript
const Storage = {
|
|
get: (key) => {
|
|
try {
|
|
return JSON.parse(localStorage.getItem(key));
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
},
|
|
|
|
set: (key, value) => {
|
|
try {
|
|
localStorage.setItem(key, JSON.stringify(value));
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
remove: (key) => {
|
|
try {
|
|
localStorage.removeItem(key);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
clear: () => {
|
|
try {
|
|
localStorage.clear();
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
}; |