summaryrefslogtreecommitdiffstats
path: root/src/services/local-storage/index.ts
blob: 8ed9ebfa83c0e0fe5e8e8066d12033ec287736a3 (plain)
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
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();
  },
};
class="o">: createBlock('@', { 'attr-value': { pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/, inside: { punctuation: /^=|^["']|["']$/, }, }, keyword: /\b\w+(?=\s)/, 'attr-name': /\b\w+/, }), expression: createBlock('=', grammar, className), 'class-feature': createBlock('\\+', grammar, className), standard: createBlock('', grammar, className), }, }, }; } Prism.languages['t4-templating'] = Object.defineProperty({}, 'createT4', { value: createT4, }); })(Prism);