MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / LocalOnlyStorage

Class LocalOnlyStorage

static/local.ts:37–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37class LocalOnlyStorage implements Storage {
38 get<T>(key: string, ifNotPresent: T): string | T {
39 try {
40 return window.localStorage.getItem(prefix + key) ?? ifNotPresent;
41 } catch {
42 // Swallow up any security exceptions...
43 return ifNotPresent;
44 }
45 }
46
47 remove(key: string) {
48 try {
49 window.localStorage.removeItem(prefix + key);
50 } catch {
51 // Swallow up any security exceptions...
52 }
53 }
54
55 set(key: string, value: string): boolean {
56 try {
57 window.localStorage.setItem(prefix + key, value);
58 return true;
59 } catch {
60 // Swallow up any security exceptions...
61 }
62 return false;
63 }
64}
65
66export const localStorage = new LocalOnlyStorage();
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected