@instantdb/core
Version:
Instant's core local abstraction
26 lines • 678 B
JavaScript
import { StoreInterface, } from './utils/PersistedObject.js';
export default class InMemoryStore extends StoreInterface {
store;
constructor(appId, dbName) {
super(appId, dbName);
this.store = new Map();
}
async getItem(k) {
return this.store.get(k) ?? null;
}
async setItem(k, v) {
this.store.set(k, v);
}
async getAllKeys() {
return [...this.store.keys()];
}
async multiSet(keyValuePairs) {
for (const [k, v] of keyValuePairs) {
this.setItem(k, v);
}
}
async removeItem(key) {
this.store.delete(key);
}
}
//# sourceMappingURL=InMemoryStorage.js.map