aboutsummaryrefslogtreecommitdiff
path: root/demo/src/utils/editor-history.util.ts
blob: 33d1916ace66e67137a587ed1c24a85fea018d09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const AVRJS8_EDITOR_HISTORY = 'AVRJS8_EDITOR_HISTORY';

export class EditorHistoryUtil {
  static storeSnippet(codeSnippet: string) {
    if (window.localStorage) {
      window.localStorage.setItem(AVRJS8_EDITOR_HISTORY, codeSnippet);
    } else throw new Error('no localStorage support');
  }

  static clearSnippet() {
    localStorage.removeItem(AVRJS8_EDITOR_HISTORY);
  }

  static getValue() {
    return localStorage.getItem(AVRJS8_EDITOR_HISTORY);
  }
}