UNPKG

@bitblit/ratchet-aws

Version:

Common tools for use with AWS browser and node

35 lines 1.05 kB
import { Logger } from '@bitblit/ratchet-common/logger/logger'; export class MemoryRuntimeParameterProvider { inData; _data; constructor(inData) { this.inData = inData; if (inData) { this._data = inData; } else { this._data = Promise.resolve({}); } } async readParameter(groupId, paramKey) { Logger.silly('Reading %s / %s from underlying db', groupId, paramKey); const d = await this._data; return d[groupId + '::' + paramKey] ?? null; } async readAllParametersForGroup(groupId) { const d = await this._data; const out = []; Object.keys(d).forEach((k) => { if (k.startsWith(groupId)) { out.push(d[k]); } }); return out; } async writeParameter(toStore) { const d = await this._data; d[toStore.groupId + '::' + toStore.paramKey] = toStore; return true; } } //# sourceMappingURL=memory-runtime-parameter-provider.js.map