Jerko Steiner 27d2459e1d Make socket.ts asynchronous
Also do not monkey-patch socket objects with user ids.
2020-03-13 20:28:46 +01:00

26 lines
550 B
TypeScript

import { Store } from './store'
export class MemoryStore implements Store {
store: Record<string, string> = {}
async getMany(keys: string[]): Promise<Array<string | undefined>> {
return keys.map(key => this.syncGet(key))
}
private syncGet(key: string): string | undefined {
return this.store[key]
}
async get(key: string): Promise<string | undefined> {
return this.syncGet(key)
}
async set(key: string, value: string) {
this.store[key] = value
}
async remove(key: string) {
delete this.store[key]
}
}