1 |
- {"version":3,"sources":["../src/makeConfig.js"],"names":["makeBorder","border","Object","assign","makeColumns","rows","columns","columnDefault","maximumColumnWidthIndex","_","times","length","index","isUndefined","alignment","paddingLeft","paddingRight","truncate","Infinity","width","wrapWord","userConfig","config","cloneDeep","drawHorizontalLine"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA;;;;;;AAMA,MAAMA,UAAU,GAAG,CAACC,MAAM,GAAG,EAAV,KAAiB;AAClC,SAAOC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB,kCAAoB,WAApB,CAAlB,EAAoDF,MAApD,CAAP;AACD,CAFD;AAIA;;;;;;;;;;;AASA,MAAMG,WAAW,GAAG,CAACC,IAAD,EAAOC,OAAO,GAAG,EAAjB,EAAqBC,aAAa,GAAG,EAArC,KAA4C;AAC9D,QAAMC,uBAAuB,GAAG,+CAAiCH,IAAjC,CAAhC;;AAEAI,kBAAEC,KAAF,CAAQL,IAAI,CAAC,CAAD,CAAJ,CAAQM,MAAhB,EAAyBC,KAAD,IAAW;AACjC,QAAIH,gBAAEI,WAAF,CAAcP,OAAO,CAACM,KAAD,CAArB,CAAJ,EAAmC;AACjCN,MAAAA,OAAO,CAACM,KAAD,CAAP,GAAiB,EAAjB;AACD;;AAEDN,IAAAA,OAAO,CAACM,KAAD,CAAP,GAAiBV,MAAM,CAACC,MAAP,CAAc;AAC7BW,MAAAA,SAAS,EAAE,MADkB;AAE7BC,MAAAA,WAAW,EAAE,CAFgB;AAG7BC,MAAAA,YAAY,EAAE,CAHe;AAI7BC,MAAAA,QAAQ,EAAEC,QAJmB;AAK7BC,MAAAA,KAAK,EAAEX,uBAAuB,CAACI,KAAD,CALD;AAM7BQ,MAAAA,QAAQ,EAAE;AANmB,KAAd,EAOdb,aAPc,EAOCD,OAAO,CAACM,KAAD,CAPR,CAAjB;AAQD,GAbD;;AAeA,SAAON,OAAP;AACD,CAnBD;AAqBA;;;;;;;;;;oBAQgBD,I,EAAMgB,UAAU,GAAG,E,KAAO;AACxC,+BAAe,aAAf,EAA8BA,UAA9B;;AAEA,QAAMC,MAAM,GAAGb,gBAAEc,SAAF,CAAYF,UAAZ,CAAf;;AAEAC,EAAAA,MAAM,CAACrB,MAAP,GAAgBD,UAAU,CAACsB,MAAM,CAACrB,MAAR,CAA1B;AACAqB,EAAAA,MAAM,CAAChB,OAAP,GAAiBF,WAAW,CAACC,IAAD,EAAOiB,MAAM,CAAChB,OAAd,EAAuBgB,MAAM,CAACf,aAA9B,CAA5B;;AAEA,MAAI,CAACe,MAAM,CAACE,kBAAZ,EAAgC;AAC9B;;;AAGAF,IAAAA,MAAM,CAACE,kBAAP,GAA4B,MAAM;AAChC,aAAO,IAAP;AACD,KAFD;AAGD;;AAED,SAAOF,MAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\nimport calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nconst makeBorder = (border = {}) => {\n return Object.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nconst makeColumns = (rows, columns = {}, columnDefault = {}) => {\n const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);\n\n _.times(rows[0].length, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = Object.assign({\n alignment: 'left',\n paddingLeft: 1,\n paddingRight: 1,\n truncate: Infinity,\n width: maximumColumnWidthIndex[index],\n wrapWord: false\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (rows, userConfig = {}) => {\n validateConfig('config.json', userConfig);\n\n const config = _.cloneDeep(userConfig);\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(rows, config.columns, config.columnDefault);\n\n if (!config.drawHorizontalLine) {\n /**\n * @returns {boolean}\n */\n config.drawHorizontalLine = () => {\n return true;\n };\n }\n\n return config;\n};\n"],"file":"makeConfig.js"}
|