@nent/core
Version:
23 lines (22 loc) • 482 B
JavaScript
/*!
* NENT 2022
*/
/* istanbul ignore file */
import { EventEmitter } from '../../common/emitter';
import { DATA_EVENTS } from '../interfaces';
export class InMemoryProvider {
constructor() {
this.data = {};
this.changed = new EventEmitter();
}
async get(key) {
return this.data[key] || null;
}
async set(key, value) {
this.data[key] = value;
this.changed.emit(DATA_EVENTS.DataChanged);
}
destroy() {
this.changed.removeAllListeners();
}
}