2022-04-08 10:22:39 +00:00
|
|
|
class LocalStorage {
|
|
|
|
constructor(key) {
|
|
|
|
this.key = key;
|
|
|
|
}
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-04-08 10:22:39 +00:00
|
|
|
store(allItems) {
|
|
|
|
localStorage.setItem(this.key, JSON.stringify(allItems));
|
|
|
|
localStorage.setItem(this.key + ':ts', Date.now());
|
|
|
|
}
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-04-08 10:22:39 +00:00
|
|
|
get() {
|
|
|
|
let stored = localStorage.getItem(this.key);
|
|
|
|
return JSON.parse(stored) || [];
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-04-08 10:22:39 +00:00
|
|
|
export default LocalStorage;
|