1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
export const LocalStorage = { get(key: string): string | null | undefined { try { const serialItem = localStorage.getItem(key); if (!serialItem) return undefined; return JSON.parse(serialItem); } catch (e) { console.log(e); return undefined; } }, set(key: string, value: string) { try { const serialItem = JSON.stringify(value); localStorage.setItem(key, serialItem); } catch (e) { console.log(e); } }, remove(key: string) { localStorage.removeItem(key); }, clear() { localStorage.clear(); }, }; www.armandphilippot.com' title='www.armandphilippot.com Git repository'/>