Created
March 26, 2020 17:14
-
-
Save wilk/ef8676ac5b0e8398a527f7f1a299c3c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function InMemoryStorage() { | |
return { | |
store: <T>(): Map<string, T> => new Map(), | |
set: <T>(key: string, value: T) => (store: Map<string, T>) => store.set(key, value), | |
get: <T>(key: string) => (store: Map<string, T>): T => store.get(key), | |
}; | |
} | |
const storage = InMemoryStorage(); | |
const store = storage.store(); | |
storage.set<number>('a', 10)(store); | |
const val = storage.get<number>('a')(store); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment