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

Function createMemoryStorage

apps/kimi-web/test/workspace-state.test.ts:137–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135}
136
137function createMemoryStorage(): Storage {
138 const data = new Map<string, string>();
139 return {
140 get length() {
141 return data.size;
142 },
143 clear() {
144 data.clear();
145 },
146 getItem(key: string) {
147 return data.get(key) ?? null;
148 },
149 key(index: number) {
150 return Array.from(data.keys()).at(index) ?? null;
151 },
152 removeItem(key: string) {
153 data.delete(key);
154 },
155 setItem(key: string, value: string) {
156 data.set(key, String(value));
157 },
158 };
159}
160
161function installStorage(storage: Storage): void {
162 Object.defineProperty(globalThis, 'localStorage', {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected