UNPKG

@serenity-js/core

Version:

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

48 lines 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = void 0; /** * @experimental */ 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; }, {}); } } exports.Config = Config; //# sourceMappingURL=Config.js.map