mirror of
https://github.com/coder/coder.git
synced 2026-11-15 14:11:53 +08:00
23 lines
511 B
TypeScript
23 lines
511 B
TypeScript
export const localStorageMock = () => {
|
|
const store = {} as Record<string, string>;
|
|
|
|
return {
|
|
getItem: (key: string): string => {
|
|
return store[key];
|
|
},
|
|
setItem: (key: string, value: string) => {
|
|
store[key] = value;
|
|
},
|
|
clear: () => {
|
|
Object.keys(store).forEach((key) => {
|
|
delete store[key];
|
|
});
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete store[key];
|
|
},
|
|
};
|
|
};
|
|
|
|
Object.defineProperty(window, "localStorage", { value: localStorageMock() });
|