mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
3.4 KiB
1 line
3.4 KiB
9 years ago
|
{"version":3,"sources":["makeConfig.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI,UAAU,YAAA;IACV,WAAW,YAAA;;;;;;;;AAAC,AAQhB,UAAU,GAAG,sBAAiB;QAAhB,MAAM,yDAAG,EAAE;;AACrB,WAAO,sBAAS,EAAE,EAAE,mCAAoB,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;CACjE;;;;;;;;;;;AAAC,AAWF,WAAW,GAAG,qBAAC,IAAI,EAAuC;QAArC,OAAO,yDAAG,EAAE;QAAE,aAAa,yDAAG,EAAE;;AACjD,QAAI,uBAAuB,YAAA,CAAC;;AAE5B,2BAAuB,GAAG,gDAAiC,IAAI,CAAC,CAAC;;AAEjE,yBAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,UAAC,KAAK,EAAK;AAC/B,YAAI,2BAAc,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;AAC/B,mBAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SACvB;;AAED,eAAO,CAAC,KAAK,CAAC,GAAG,sBAAS;AACtB,qBAAS,EAAE,MAAM;AACjB,iBAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC;AACrC,oBAAQ,EAAE,KAAK;AACf,oBAAQ,EAAE,QAAQ;AAClB,uBAAW,EAAE,CAAC;AACd,wBAAY,EAAE,CAAC;SAClB,EAAE,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;KACrC,CAAC,CAAC;;AAEH,WAAO,OAAO,CAAC;CAClB;;;;;;;;;;AAAC;kBAUa,UAAC,IAAI,EAAsB;QAApB,UAAU,yDAAG,EAAE;;AACjC,QAAI,MAAM,YAAA,CAAC;;AAEX,kCAAe,UAAU,CAAC,CAAC;;AAE3B,UAAM,GAAG,yBAAY,UAAU,CAAC,CAAC;;AAEjC,UAAM,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1C,UAAM,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;;AAEzE,QAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;;;;AAI5B,cAAM,CAAC,kBAAkB,GAAG,YAAM;AAC9B,mBAAO,IAAI,CAAC;SACf,CAAC;KACL;;AAED,WAAO,MAAM,CAAC;CACjB","file":"makeConfig.js","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\nimport calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';\n\nlet makeBorder,\n makeColumns;\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nmakeBorder = (border = {}) => {\n return _.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 */\nmakeColumns = (rows, columns = {}, columnDefault = {}) => {\n let maximumColumnWidthIndex;\n\n maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);\n\n _.times(rows[0].length, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = _.assign({\n alignment: 'left',\n width: maximumColumnWidthIndex[index],\n wrapWord: false,\n truncate: Infinity,\n paddingLeft: 1,\n paddingRight: 1\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 let config;\n\n validateConfig(userConfig);\n\n 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"],"sourceRoot":"/source/"}
|