/ cloudformation-templates / node_modules / aws-cdk / node_modules / table / dist / makeStreamConfig.js
makeStreamConfig.js
1 "use strict"; 2 var __importDefault = (this && this.__importDefault) || function (mod) { 3 return (mod && mod.__esModule) ? mod : { "default": mod }; 4 }; 5 Object.defineProperty(exports, "__esModule", { value: true }); 6 exports.makeStreamConfig = void 0; 7 const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); 8 const utils_1 = require("./utils"); 9 const validateConfig_1 = require("./validateConfig"); 10 /** 11 * Creates a configuration for every column using default 12 * values for the missing configuration properties. 13 */ 14 const makeColumnsConfig = (columnCount, columns = {}, columnDefault) => { 15 return Array.from({ length: columnCount }).map((_, index) => { 16 return { 17 alignment: 'left', 18 paddingLeft: 1, 19 paddingRight: 1, 20 truncate: Number.POSITIVE_INFINITY, 21 verticalAlignment: 'top', 22 wrapWord: false, 23 ...columnDefault, 24 ...columns[index], 25 }; 26 }); 27 }; 28 /** 29 * Makes a new configuration object out of the userConfig object 30 * using default values for the missing configuration properties. 31 */ 32 const makeStreamConfig = (userConfig) => { 33 validateConfig_1.validateConfig('streamConfig.json', userConfig); 34 const config = lodash_clonedeep_1.default(userConfig); 35 if (config.columnDefault.width === undefined) { 36 throw new Error('Must provide config.columnDefault.width when creating a stream.'); 37 } 38 return { 39 drawVerticalLine: () => { 40 return true; 41 }, 42 ...config, 43 border: utils_1.makeBorderConfig(config.border), 44 columns: makeColumnsConfig(config.columnCount, config.columns, config.columnDefault), 45 }; 46 }; 47 exports.makeStreamConfig = makeStreamConfig;