table 5.0.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/createStream.js
CHANGED
|
@@ -91,10 +91,12 @@ const append = (row, columnWidthIndex, config) => {
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
const createStream = (userConfig = {}) => {
|
|
94
|
-
const config = (0, _makeStreamConfig.default)(userConfig);
|
|
95
|
-
|
|
94
|
+
const config = (0, _makeStreamConfig.default)(userConfig); // @todo Use 'Object.values' when Node.js v6 support is dropped.
|
|
95
|
+
|
|
96
|
+
const columnWidthIndex = _lodash.default.values(_lodash.default.mapValues(config.columns, column => {
|
|
96
97
|
return column.width + column.paddingLeft + column.paddingRight;
|
|
97
98
|
}));
|
|
99
|
+
|
|
98
100
|
let empty;
|
|
99
101
|
empty = true;
|
|
100
102
|
return {
|
|
@@ -93,7 +93,8 @@ const append = (row, columnWidthIndex, config) => {
|
|
|
93
93
|
export default (userConfig = {}) => {
|
|
94
94
|
const config = makeStreamConfig(userConfig);
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
// @todo Use 'Object.values' when Node.js v6 support is dropped.
|
|
97
|
+
const columnWidthIndex = _.values(_.mapValues(config.columns, (column) => {
|
|
97
98
|
return column.width + column.paddingLeft + column.paddingRight;
|
|
98
99
|
}));
|
|
99
100
|
|
package/dist/createStream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createStream.js"],"names":["prepareData","data","config","rows","rowHeightIndex","create","row","columnWidthIndex","body","map","literalRow","border","join","output","_","trimEnd","process","stdout","write","append","userConfig","
|
|
1
|
+
{"version":3,"sources":["../src/createStream.js"],"names":["prepareData","data","config","rows","rowHeightIndex","create","row","columnWidthIndex","body","map","literalRow","border","join","output","_","trimEnd","process","stdout","write","append","userConfig","values","mapValues","columns","column","width","paddingLeft","paddingRight","empty","length","columnCount","Error"],"mappings":";;;;;;;AAAA;;AACA;;AAC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,WAA1B,EAAuC;AACrC,cAAM,IAAIC,KAAJ,CAAU,uDAAV,CAAN;AACD;;AAED,UAAIH,KAAJ,EAAW;AACTA,QAAAA,KAAK,GAAG,KAAR;AAEA,eAAOvB,MAAM,CAACC,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,CAAb;AACD,OAJD,MAIO;AACL,eAAOiB,MAAM,CAACb,GAAD,EAAMC,gBAAN,EAAwBL,MAAxB,CAAb;AACD;AACF;AAjBI,GAAP;AAmBD,C","sourcesContent":["import _ from 'lodash';\nimport makeStreamConfig from './makeStreamConfig';\nimport drawRow from './drawRow';\nimport {\n drawBorderBottom,\n drawBorderJoin,\n drawBorderTop\n} from './drawBorder';\nimport stringifyTableData from './stringifyTableData';\nimport truncateTableData from './truncateTableData';\nimport mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';\nimport alignTableData from './alignTableData';\nimport padTableData from './padTableData';\nimport calculateRowHeightIndex from './calculateRowHeightIndex';\n\n/**\n * @param {Array} data\n * @param {Object} config\n * @returns {Array}\n */\nconst prepareData = (data, config) => {\n let rows;\n\n rows = stringifyTableData(data);\n\n rows = truncateTableData(data, config);\n\n const rowHeightIndex = calculateRowHeightIndex(rows, config);\n\n rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);\n rows = alignTableData(rows, config);\n rows = padTableData(rows, config);\n\n return rows;\n};\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\nconst create = (row, columnWidthIndex, config) => {\n const rows = prepareData([row], config);\n\n const body = rows.map((literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n let output;\n\n output = '';\n\n output += drawBorderTop(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\nconst append = (row, columnWidthIndex, config) => {\n const rows = prepareData([row], config);\n\n const body = rows.map((literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n let output;\n\n output = '\\r\\u001B[K';\n\n output += drawBorderJoin(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (userConfig = {}) => {\n const config = makeStreamConfig(userConfig);\n\n // @todo Use 'Object.values' when Node.js v6 support is dropped.\n const columnWidthIndex = _.values(_.mapValues(config.columns, (column) => {\n return column.width + column.paddingLeft + column.paddingRight;\n }));\n\n let empty;\n\n empty = true;\n\n return {\n /**\n * @param {string[]} row\n * @returns {undefined}\n */\n write: (row) => {\n if (row.length !== config.columnCount) {\n throw new Error('Row cell count does not match the config.columnCount.');\n }\n\n if (empty) {\n empty = false;\n\n return create(row, columnWidthIndex, config);\n } else {\n return append(row, columnWidthIndex, config);\n }\n }\n };\n};\n"],"file":"createStream.js"}
|
package/dist/validateConfig.js
CHANGED
package/package.json
CHANGED
|
@@ -5,39 +5,39 @@
|
|
|
5
5
|
"url": "http://gajus.com"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"ajv": "^6.
|
|
9
|
-
"lodash": "^4.17.
|
|
10
|
-
"slice-ansi": "
|
|
8
|
+
"ajv": "^6.6.1",
|
|
9
|
+
"lodash": "^4.17.11",
|
|
10
|
+
"slice-ansi": "2.0.0",
|
|
11
11
|
"string-width": "^2.1.1"
|
|
12
12
|
},
|
|
13
13
|
"description": "Formats data into a string table.",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@babel/cli": "^7.
|
|
16
|
-
"@babel/core": "^7.
|
|
15
|
+
"@babel/cli": "^7.1.5",
|
|
16
|
+
"@babel/core": "^7.1.6",
|
|
17
17
|
"@babel/node": "^7.0.0",
|
|
18
|
-
"@babel/plugin-transform-flow-strip-types": "^7.
|
|
19
|
-
"@babel/preset-env": "^7.
|
|
18
|
+
"@babel/plugin-transform-flow-strip-types": "^7.1.6",
|
|
19
|
+
"@babel/preset-env": "^7.1.6",
|
|
20
20
|
"@babel/register": "^7.0.0",
|
|
21
21
|
"ajv-cli": "^3.0.0",
|
|
22
22
|
"ajv-keywords": "^3.2.0",
|
|
23
|
-
"babel-plugin-istanbul": "^5.0
|
|
23
|
+
"babel-plugin-istanbul": "^5.1.0",
|
|
24
24
|
"babel-plugin-transform-export-default-name": "^2.0.4",
|
|
25
|
-
"chai": "^4.
|
|
25
|
+
"chai": "^4.2.0",
|
|
26
26
|
"chalk": "^2.4.1",
|
|
27
27
|
"coveralls": "^3.0.2",
|
|
28
|
-
"eslint": "^5.
|
|
29
|
-
"eslint-config-canonical": "^
|
|
30
|
-
"flow-bin": "^0.
|
|
28
|
+
"eslint": "^5.9.0",
|
|
29
|
+
"eslint-config-canonical": "^13.0.0",
|
|
30
|
+
"flow-bin": "^0.87.0",
|
|
31
31
|
"flow-copy-source": "^2.0.2",
|
|
32
|
-
"gitdown": "^2.5.
|
|
33
|
-
"husky": "^1.
|
|
32
|
+
"gitdown": "^2.5.5",
|
|
33
|
+
"husky": "^1.2.0",
|
|
34
34
|
"mocha": "^5.2.0",
|
|
35
|
-
"nyc": "^13.0
|
|
36
|
-
"semantic-release": "^15.
|
|
37
|
-
"sinon": "^
|
|
35
|
+
"nyc": "^13.1.0",
|
|
36
|
+
"semantic-release": "^15.12.3",
|
|
37
|
+
"sinon": "^7.1.1"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
|
-
"node": ">=
|
|
40
|
+
"node": ">=6.0.0"
|
|
41
41
|
},
|
|
42
42
|
"husky": {
|
|
43
43
|
"hooks": {
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"lint": "npm run build && eslint ./src ./test && flow",
|
|
80
80
|
"test": "mocha --require @babel/register"
|
|
81
81
|
},
|
|
82
|
-
"version": "5.
|
|
82
|
+
"version": "5.1.1"
|
|
83
83
|
}
|