MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / createMemoryStorage

Function createMemoryStorage

apps/kimi-web/test/notification-logic.test.ts:5–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useNotification } from '../src/composables/client/useNotification';
4
5function createMemoryStorage(): Storage {
6 const data = new Map<string, string>();
7 return {
8 get length() {
9 return data.size;
10 },
11 clear() {
12 data.clear();
13 },
14 getItem(key: string) {
15 return data.get(key) ?? null;
16 },
17 key(index: number) {
18 return Array.from(data.keys()).at(index) ?? null;
19 },
20 removeItem(key: string) {
21 data.delete(key);
22 },
23 setItem(key: string, value: string) {
24 data.set(key, value);
25 },
26 };
27}
28
29function installStorage(storage: Storage): void {
30 Object.defineProperty(globalThis, 'localStorage', {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected