MCPcopy Create free account
hub / github.com/dailydotdev/apps / readStorage

Function readStorage

packages/shared/src/lib/liveRoom/resumeSessionStorage.ts:12–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10const fallbackStorage = new Map<string, string>();
11
12const readStorage = (): Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> => {
13 try {
14 if (typeof window !== 'undefined' && window.sessionStorage) {
15 return window.sessionStorage;
16 }
17 } catch {
18 // Fall through to the in-memory store.
19 }
20
21 return {
22 getItem: (key) => fallbackStorage.get(key) ?? null,
23 setItem: (key, value) => {
24 fallbackStorage.set(key, value);
25 },
26 removeItem: (key) => {
27 fallbackStorage.delete(key);
28 },
29 };
30};
31
32const getStorageKey = (roomId: string): string =>
33 `${storageKeyPrefix}${roomId}`;

Calls

no outgoing calls

Tested by

no test coverage detected