UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

44 lines 1.13 kB
/** * @experimental */ export class Config { config; transformations = new Map(); constructor(config) { this.config = config; } where(fieldName, transformation) { this.transformations.set(fieldName, transformation); return this; } whereIf(condition, fieldName, transformation) { if (condition === true) { this.transformations.set(fieldName, transformation); } return this; } keys() { return Object.keys(this.config); } has(key) { return Object.prototype.hasOwnProperty.call(this.config, key); } get(key) { return this.transformations.has(key) ? this.transformations.get(key)(this.config[key]) : this.config[key]; } getAsList(key) { const value = this.get(key); return value !== null && value !== undefined ? [].concat(value) : []; } object() { return this.keys().reduce((acc, key) => { acc[key] = this.get(key); return acc; }, {}); } } //# sourceMappingURL=Config.js.map