Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 36x 36x 4x 13x 11x 9x 2x 2x 1x 1x 1x 3x | import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class DataStorageService { getRawItem(key: string): string | null { return window.localStorage.getItem(key); } getItem<T>(key: string) : T | null { const item = window.localStorage.getItem(key); Eif(item === null) { return null; } try { return JSON.parse(item) as T; } catch(e) { console.log(e); return null; } } removeItem(key: string): void { window.localStorage.removeItem(key); } setItem(key: string, value: any): void { window.localStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value)); } } |