MCPcopy
hub / github.com/coder/mux / MemoryStorage

Class MemoryStorage

src/browser/contexts/UserPreferencesContext.test.ts:23–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21import type { UserPreferences } from "@/common/config/schemas/userPreferences";
22
23class MemoryStorage implements Storage {
24 private values = new Map<string, string>();
25
26 get length() {
27 return this.values.size;
28 }
29
30 clear(): void {
31 this.values.clear();
32 }
33
34 getItem(key: string): string | null {
35 return this.values.get(key) ?? null;
36 }
37
38 key(index: number): string | null {
39 return Array.from(this.values.keys())[index] ?? null;
40 }
41
42 removeItem(key: string): void {
43 this.values.delete(key);
44 }
45
46 setItem(key: string, value: string): void {
47 this.values.set(key, value);
48 }
49
50 setJSON(key: string, value: unknown): void {
51 this.setItem(key, JSON.stringify(value));
52 }
53}
54
55async function waitUntil(assertion: () => void): Promise<void> {
56 const deadline = Date.now() + 1000;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected