table 6.0.6 → 6.1.0
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/README.md +52 -1
- package/dist/alignString.js +6 -7
- package/dist/alignString.js.flow +5 -4
- package/dist/alignTableData.js +1 -2
- package/dist/calculateCellHeight.js +3 -4
- package/dist/calculateCellHeight.js.flow +2 -2
- package/dist/calculateCellWidthIndex.js +1 -2
- package/dist/calculateMaximumColumnWidthIndex.js +1 -2
- package/dist/calculateRowHeightIndex.js +6 -9
- package/dist/calculateRowHeightIndex.js.flow +5 -4
- package/dist/createStream.js +13 -16
- package/dist/createStream.js.flow +12 -13
- package/dist/drawBorder.js +58 -53
- package/dist/drawBorder.js.flow +43 -55
- package/dist/drawHorizontalContent.js +41 -0
- package/dist/drawHorizontalContent.js.flow +31 -0
- package/dist/drawRow.js +21 -6
- package/dist/drawRow.js.flow +18 -4
- package/dist/drawTable.js +12 -11
- package/dist/drawTable.js.flow +24 -13
- package/dist/getBorderCharacters.js +1 -2
- package/dist/index.js +1 -2
- package/dist/makeConfig.js +19 -13
- package/dist/makeConfig.js.flow +16 -7
- package/dist/makeStreamConfig.js +17 -11
- package/dist/makeStreamConfig.js.flow +14 -5
- package/dist/mapDataUsingRowHeightIndex.js +4 -7
- package/dist/mapDataUsingRowHeightIndex.js.flow +3 -3
- package/dist/padTableData.js +1 -2
- package/dist/schemas/config.json +6 -0
- package/dist/schemas/streamConfig.json +3 -0
- package/dist/stringifyTableData.js +1 -2
- package/dist/table.js +14 -3
- package/dist/table.js.flow +13 -1
- package/dist/truncateTableData.js +3 -4
- package/dist/truncateTableData.js.flow +2 -2
- package/dist/validateConfig.js +1 -4
- package/dist/validateConfig.js.flow +0 -1
- package/dist/validateTableData.js +1 -2
- package/dist/validators.js +247 -186
- package/dist/wrapCell.js +1 -2
- package/dist/wrapString.js +1 -2
- package/dist/wrapWord.js +1 -2
- package/package.json +14 -8
- package/dist/alignString.js.map +0 -1
- package/dist/alignTableData.js.map +0 -1
- package/dist/calculateCellHeight.js.map +0 -1
- package/dist/calculateCellWidthIndex.js.map +0 -1
- package/dist/calculateMaximumColumnWidthIndex.js.map +0 -1
- package/dist/calculateRowHeightIndex.js.map +0 -1
- package/dist/createStream.js.map +0 -1
- package/dist/drawBorder.js.map +0 -1
- package/dist/drawRow.js.map +0 -1
- package/dist/drawTable.js.map +0 -1
- package/dist/getBorderCharacters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/makeConfig.js.map +0 -1
- package/dist/makeStreamConfig.js.map +0 -1
- package/dist/mapDataUsingRowHeightIndex.js.map +0 -1
- package/dist/padTableData.js.map +0 -1
- package/dist/stringifyTableData.js.map +0 -1
- package/dist/table.js.map +0 -1
- package/dist/truncateTableData.js.map +0 -1
- package/dist/validateConfig.js.map +0 -1
- package/dist/validateTableData.js.map +0 -1
- package/dist/wrapCell.js.map +0 -1
- package/dist/wrapString.js.map +0 -1
- package/dist/wrapWord.js.map +0 -1
package/dist/drawBorder.js.flow
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import drawHorizontalContent from './drawHorizontalContent';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* @typedef drawBorder~
|
|
4
|
+
* @typedef drawBorder~border
|
|
3
5
|
* @property {string} left
|
|
4
6
|
* @property {string} right
|
|
5
7
|
* @property {string} body
|
|
@@ -8,88 +10,74 @@
|
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @param {number[]} columnSizeIndex
|
|
11
|
-
* @param {
|
|
13
|
+
* @param {object} config
|
|
14
|
+
* @param {drawBorder~border} config.border
|
|
15
|
+
* @param {Function} config.drawVerticalLine
|
|
12
16
|
* @returns {string}
|
|
13
17
|
*/
|
|
14
|
-
const drawBorder = (columnSizeIndex,
|
|
15
|
-
const columns = columnSizeIndex
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
.join(parts.join);
|
|
18
|
+
const drawBorder = (columnSizeIndex, {border, drawVerticalLine}) => {
|
|
19
|
+
const columns = columnSizeIndex.map((size) => {
|
|
20
|
+
return border.body.repeat(size);
|
|
21
|
+
});
|
|
20
22
|
|
|
21
|
-
return
|
|
23
|
+
return drawHorizontalContent(columns, {
|
|
24
|
+
drawVerticalLine,
|
|
25
|
+
separator: border,
|
|
26
|
+
});
|
|
22
27
|
};
|
|
23
28
|
|
|
24
|
-
/**
|
|
25
|
-
* @typedef drawBorderTop~parts
|
|
26
|
-
* @property {string} topLeft
|
|
27
|
-
* @property {string} topRight
|
|
28
|
-
* @property {string} topBody
|
|
29
|
-
* @property {string} topJoin
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
29
|
/**
|
|
33
30
|
* @param {number[]} columnSizeIndex
|
|
34
|
-
* @param {
|
|
31
|
+
* @param {table~config} config
|
|
35
32
|
* @returns {string}
|
|
36
33
|
*/
|
|
37
|
-
const drawBorderTop = (columnSizeIndex,
|
|
38
|
-
const
|
|
39
|
-
body:
|
|
40
|
-
join:
|
|
41
|
-
left:
|
|
42
|
-
right:
|
|
43
|
-
}
|
|
34
|
+
const drawBorderTop = (columnSizeIndex, {border, drawVerticalLine}) => {
|
|
35
|
+
const result = drawBorder(columnSizeIndex, {border: {
|
|
36
|
+
body: border.topBody,
|
|
37
|
+
join: border.topJoin,
|
|
38
|
+
left: border.topLeft,
|
|
39
|
+
right: border.topRight,
|
|
40
|
+
},
|
|
41
|
+
drawVerticalLine});
|
|
44
42
|
|
|
45
|
-
if (
|
|
43
|
+
if (result === '\n') {
|
|
46
44
|
return '';
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
return
|
|
47
|
+
return result;
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
/**
|
|
53
|
-
* @typedef drawBorderJoin~parts
|
|
54
|
-
* @property {string} joinLeft
|
|
55
|
-
* @property {string} joinRight
|
|
56
|
-
* @property {string} joinBody
|
|
57
|
-
* @property {string} joinJoin
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
50
|
/**
|
|
61
51
|
* @param {number[]} columnSizeIndex
|
|
62
|
-
* @param {
|
|
52
|
+
* @param {table~config} config
|
|
63
53
|
* @returns {string}
|
|
64
54
|
*/
|
|
65
|
-
const drawBorderJoin = (columnSizeIndex,
|
|
55
|
+
const drawBorderJoin = (columnSizeIndex, {border, drawVerticalLine}) => {
|
|
66
56
|
return drawBorder(columnSizeIndex, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
border: {
|
|
58
|
+
body: border.joinBody,
|
|
59
|
+
join: border.joinJoin,
|
|
60
|
+
left: border.joinLeft,
|
|
61
|
+
right: border.joinRight,
|
|
62
|
+
},
|
|
63
|
+
drawVerticalLine,
|
|
71
64
|
});
|
|
72
65
|
};
|
|
73
66
|
|
|
74
|
-
/**
|
|
75
|
-
* @typedef drawBorderBottom~parts
|
|
76
|
-
* @property {string} topLeft
|
|
77
|
-
* @property {string} topRight
|
|
78
|
-
* @property {string} topBody
|
|
79
|
-
* @property {string} topJoin
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
67
|
/**
|
|
83
68
|
* @param {number[]} columnSizeIndex
|
|
84
|
-
* @param {
|
|
69
|
+
* @param {table~config} config
|
|
85
70
|
* @returns {string}
|
|
86
71
|
*/
|
|
87
|
-
const drawBorderBottom = (columnSizeIndex,
|
|
72
|
+
const drawBorderBottom = (columnSizeIndex, {border, drawVerticalLine}) => {
|
|
88
73
|
return drawBorder(columnSizeIndex, {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
border: {
|
|
75
|
+
body: border.bottomBody,
|
|
76
|
+
join: border.bottomJoin,
|
|
77
|
+
left: border.bottomLeft,
|
|
78
|
+
right: border.bottomRight,
|
|
79
|
+
},
|
|
80
|
+
drawVerticalLine,
|
|
93
81
|
});
|
|
94
82
|
};
|
|
95
83
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} drawHorizontalContent~separator
|
|
10
|
+
* @property {string} left
|
|
11
|
+
* @property {string} right
|
|
12
|
+
* @property {string} join
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string[]} columns
|
|
17
|
+
* @param {object} config
|
|
18
|
+
* @param {drawHorizontalContent~separator} config.separator
|
|
19
|
+
* @param {Function} config.drawVerticalLine
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
const drawHorizontalContent = (columns, {
|
|
23
|
+
separator,
|
|
24
|
+
drawVerticalLine
|
|
25
|
+
}) => {
|
|
26
|
+
const columnCount = columns.length;
|
|
27
|
+
const result = [];
|
|
28
|
+
result.push(drawVerticalLine(0, columnCount) ? separator.left : '');
|
|
29
|
+
columns.forEach((column, index) => {
|
|
30
|
+
result.push(column);
|
|
31
|
+
|
|
32
|
+
if (index + 1 < columnCount) {
|
|
33
|
+
result.push(drawVerticalLine(index + 1, columnCount) ? separator.join : '');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
result.push(drawVerticalLine(columnCount, columnCount) ? separator.right : '');
|
|
37
|
+
return result.join('') + '\n';
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var _default = drawHorizontalContent;
|
|
41
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} drawHorizontalContent~separator
|
|
3
|
+
* @property {string} left
|
|
4
|
+
* @property {string} right
|
|
5
|
+
* @property {string} join
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string[]} columns
|
|
10
|
+
* @param {object} config
|
|
11
|
+
* @param {drawHorizontalContent~separator} config.separator
|
|
12
|
+
* @param {Function} config.drawVerticalLine
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export default (columns, {separator, drawVerticalLine}) => {
|
|
16
|
+
const columnCount = columns.length;
|
|
17
|
+
const result = [];
|
|
18
|
+
|
|
19
|
+
result.push(drawVerticalLine(0, columnCount) ? separator.left : '');
|
|
20
|
+
|
|
21
|
+
columns.forEach((column, index) => {
|
|
22
|
+
result.push(column);
|
|
23
|
+
|
|
24
|
+
if (index + 1 < columnCount) {
|
|
25
|
+
result.push(drawVerticalLine(index + 1, columnCount) ? separator.join : '');
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
result.push(drawVerticalLine(columnCount, columnCount) ? separator.right : '');
|
|
29
|
+
|
|
30
|
+
return result.join('') + '\n';
|
|
31
|
+
};
|
package/dist/drawRow.js
CHANGED
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _drawHorizontalContent = _interopRequireDefault(require("./drawHorizontalContent"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* @typedef {object} drawRow~border
|
|
10
14
|
* @property {string} bodyLeft
|
|
@@ -13,14 +17,25 @@ exports.default = void 0;
|
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
20
|
+
* @param {string[]} columns
|
|
21
|
+
* @param {object} config
|
|
22
|
+
* @param {border} config.border
|
|
23
|
+
* @param {Function} config.drawVerticalLine
|
|
18
24
|
* @returns {string}
|
|
19
25
|
*/
|
|
20
|
-
const drawRow = (columns,
|
|
21
|
-
|
|
26
|
+
const drawRow = (columns, {
|
|
27
|
+
border,
|
|
28
|
+
drawVerticalLine
|
|
29
|
+
}) => {
|
|
30
|
+
return (0, _drawHorizontalContent.default)(columns, {
|
|
31
|
+
drawVerticalLine,
|
|
32
|
+
separator: {
|
|
33
|
+
join: border.bodyJoin,
|
|
34
|
+
left: border.bodyLeft,
|
|
35
|
+
right: border.bodyRight
|
|
36
|
+
}
|
|
37
|
+
});
|
|
22
38
|
};
|
|
23
39
|
|
|
24
40
|
var _default = drawRow;
|
|
25
|
-
exports.default = _default;
|
|
26
|
-
//# sourceMappingURL=drawRow.js.map
|
|
41
|
+
exports.default = _default;
|
package/dist/drawRow.js.flow
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import drawHorizontalContent from './drawHorizontalContent';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @typedef {object} drawRow~border
|
|
3
5
|
* @property {string} bodyLeft
|
|
@@ -6,10 +8,22 @@
|
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
+
* @param {string[]} columns
|
|
12
|
+
* @param {object} config
|
|
13
|
+
* @param {border} config.border
|
|
14
|
+
* @param {Function} config.drawVerticalLine
|
|
11
15
|
* @returns {string}
|
|
12
16
|
*/
|
|
13
|
-
export default (columns,
|
|
14
|
-
|
|
17
|
+
export default (columns, {
|
|
18
|
+
border,
|
|
19
|
+
drawVerticalLine,
|
|
20
|
+
}) => {
|
|
21
|
+
return drawHorizontalContent(columns, {
|
|
22
|
+
drawVerticalLine,
|
|
23
|
+
separator: {
|
|
24
|
+
join: border.bodyJoin,
|
|
25
|
+
left: border.bodyLeft,
|
|
26
|
+
right: border.bodyRight,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
15
29
|
};
|
package/dist/drawTable.js
CHANGED
|
@@ -12,15 +12,17 @@ var _drawRow = _interopRequireDefault(require("./drawRow"));
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {object} border
|
|
15
|
+
* @param {string[][]} rows
|
|
17
16
|
* @param {Array} columnSizeIndex
|
|
18
17
|
* @param {Array} rowSpanIndex
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {boolean} singleLine
|
|
18
|
+
* @param {table~config} config
|
|
21
19
|
* @returns {string}
|
|
22
20
|
*/
|
|
23
|
-
const drawTable = (rows,
|
|
21
|
+
const drawTable = (rows, columnSizeIndex, rowSpanIndex, config) => {
|
|
22
|
+
const {
|
|
23
|
+
drawHorizontalLine,
|
|
24
|
+
singleLine
|
|
25
|
+
} = config;
|
|
24
26
|
let output;
|
|
25
27
|
let realRowIndex;
|
|
26
28
|
let rowHeight;
|
|
@@ -29,11 +31,11 @@ const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi
|
|
|
29
31
|
output = '';
|
|
30
32
|
|
|
31
33
|
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
32
|
-
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex,
|
|
34
|
+
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, config);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
rows.forEach((row, index0) => {
|
|
36
|
-
output += (0, _drawRow.default)(row,
|
|
38
|
+
output += (0, _drawRow.default)(row, config);
|
|
37
39
|
|
|
38
40
|
if (!rowHeight) {
|
|
39
41
|
rowHeight = rowSpanIndex[realRowIndex];
|
|
@@ -43,17 +45,16 @@ const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi
|
|
|
43
45
|
rowHeight--;
|
|
44
46
|
|
|
45
47
|
if (!singleLine && rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
|
|
46
|
-
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex,
|
|
48
|
+
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, config);
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
51
|
-
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex,
|
|
53
|
+
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, config);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
return output;
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
var _default = drawTable;
|
|
58
|
-
exports.default = _default;
|
|
59
|
-
//# sourceMappingURL=drawTable.js.map
|
|
60
|
+
exports.default = _default;
|
package/dist/drawTable.js.flow
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
drawBorderTop,
|
|
3
|
-
drawBorderJoin,
|
|
4
|
-
drawBorderBottom,
|
|
2
|
+
drawBorderTop, drawBorderJoin, drawBorderBottom,
|
|
5
3
|
} from './drawBorder';
|
|
6
4
|
import drawRow from './drawRow';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {object} border
|
|
7
|
+
* @param {string[][]} rows
|
|
11
8
|
* @param {Array} columnSizeIndex
|
|
12
9
|
* @param {Array} rowSpanIndex
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {boolean} singleLine
|
|
10
|
+
* @param {table~config} config
|
|
15
11
|
* @returns {string}
|
|
16
12
|
*/
|
|
17
|
-
export default (
|
|
13
|
+
export default (
|
|
14
|
+
rows,
|
|
15
|
+
columnSizeIndex,
|
|
16
|
+
rowSpanIndex,
|
|
17
|
+
config,
|
|
18
|
+
) => {
|
|
19
|
+
const {
|
|
20
|
+
drawHorizontalLine,
|
|
21
|
+
singleLine,
|
|
22
|
+
} = config;
|
|
23
|
+
|
|
18
24
|
let output;
|
|
19
25
|
let realRowIndex;
|
|
20
26
|
let rowHeight;
|
|
@@ -26,11 +32,11 @@ export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine,
|
|
|
26
32
|
output = '';
|
|
27
33
|
|
|
28
34
|
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
29
|
-
output += drawBorderTop(columnSizeIndex,
|
|
35
|
+
output += drawBorderTop(columnSizeIndex, config);
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
rows.forEach((row, index0) => {
|
|
33
|
-
output += drawRow(row,
|
|
39
|
+
output += drawRow(row, config);
|
|
34
40
|
|
|
35
41
|
if (!rowHeight) {
|
|
36
42
|
rowHeight = rowSpanIndex[realRowIndex];
|
|
@@ -40,13 +46,18 @@ export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine,
|
|
|
40
46
|
|
|
41
47
|
rowHeight--;
|
|
42
48
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
49
|
+
if (
|
|
50
|
+
!singleLine &&
|
|
51
|
+
rowHeight === 0 &&
|
|
52
|
+
index0 !== rowCount - 1 &&
|
|
53
|
+
drawHorizontalLine(realRowIndex, rowCount)
|
|
54
|
+
) {
|
|
55
|
+
output += drawBorderJoin(columnSizeIndex, config);
|
|
45
56
|
}
|
|
46
57
|
});
|
|
47
58
|
|
|
48
59
|
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
49
|
-
output += drawBorderBottom(columnSizeIndex,
|
|
60
|
+
output += drawBorderBottom(columnSizeIndex, config);
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
return output;
|
package/dist/index.js
CHANGED
|
@@ -28,5 +28,4 @@ var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters
|
|
|
28
28
|
|
|
29
29
|
var _table = _interopRequireDefault(require("./table"));
|
|
30
30
|
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
31
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/makeConfig.js
CHANGED
|
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
11
|
-
|
|
12
|
-
var _times2 = _interopRequireDefault(require("lodash/times"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
13
9
|
|
|
14
10
|
var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));
|
|
15
11
|
|
|
@@ -41,8 +37,9 @@ const makeBorder = (border = {}) => {
|
|
|
41
37
|
|
|
42
38
|
const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
43
39
|
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
|
|
41
|
+
for (let index = 0; index < rows[0].length; index++) {
|
|
42
|
+
if (typeof columns[index] === 'undefined') {
|
|
46
43
|
columns[index] = {};
|
|
47
44
|
}
|
|
48
45
|
|
|
@@ -54,7 +51,8 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
|
54
51
|
width: maximumColumnWidthIndex[index],
|
|
55
52
|
wrapWord: false
|
|
56
53
|
}, columnDefault, columns[index]);
|
|
57
|
-
}
|
|
54
|
+
}
|
|
55
|
+
|
|
58
56
|
return columns;
|
|
59
57
|
};
|
|
60
58
|
/**
|
|
@@ -69,19 +67,28 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
|
69
67
|
|
|
70
68
|
const makeConfig = (rows, userConfig = {}) => {
|
|
71
69
|
(0, _validateConfig.default)('config.json', userConfig);
|
|
72
|
-
const config = (0,
|
|
70
|
+
const config = (0, _lodash.default)(userConfig);
|
|
73
71
|
config.border = makeBorder(config.border);
|
|
74
72
|
config.columns = makeColumns(rows, config.columns, config.columnDefault);
|
|
75
73
|
|
|
76
74
|
if (!config.drawHorizontalLine) {
|
|
77
75
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
* @returns {boolean}
|
|
77
|
+
*/
|
|
80
78
|
config.drawHorizontalLine = () => {
|
|
81
79
|
return true;
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
|
|
83
|
+
if (!config.drawVerticalLine) {
|
|
84
|
+
/**
|
|
85
|
+
* @returns {boolean}
|
|
86
|
+
*/
|
|
87
|
+
config.drawVerticalLine = () => {
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
if (config.singleLine === undefined) {
|
|
86
93
|
config.singleLine = false;
|
|
87
94
|
}
|
|
@@ -90,5 +97,4 @@ const makeConfig = (rows, userConfig = {}) => {
|
|
|
90
97
|
};
|
|
91
98
|
|
|
92
99
|
var _default = makeConfig;
|
|
93
|
-
exports.default = _default;
|
|
94
|
-
//# sourceMappingURL=makeConfig.js.map
|
|
100
|
+
exports.default = _default;
|
package/dist/makeConfig.js.flow
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
2
2
|
import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';
|
|
3
3
|
import getBorderCharacters from './getBorderCharacters';
|
|
4
4
|
import validateConfig from './validateConfig';
|
|
@@ -25,8 +25,8 @@ const makeBorder = (border = {}) => {
|
|
|
25
25
|
const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
26
26
|
const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
if (
|
|
28
|
+
for (let index = 0; index < rows[0].length; index++) {
|
|
29
|
+
if (typeof columns[index] === 'undefined') {
|
|
30
30
|
columns[index] = {};
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
|
38
38
|
width: maximumColumnWidthIndex[index],
|
|
39
39
|
wrapWord: false,
|
|
40
40
|
}, columnDefault, columns[index]);
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
return columns;
|
|
44
44
|
};
|
|
@@ -54,20 +54,29 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
|
54
54
|
export default (rows, userConfig = {}) => {
|
|
55
55
|
validateConfig('config.json', userConfig);
|
|
56
56
|
|
|
57
|
-
const config =
|
|
57
|
+
const config = cloneDeep(userConfig);
|
|
58
58
|
|
|
59
59
|
config.border = makeBorder(config.border);
|
|
60
60
|
config.columns = makeColumns(rows, config.columns, config.columnDefault);
|
|
61
61
|
|
|
62
62
|
if (!config.drawHorizontalLine) {
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
66
|
config.drawHorizontalLine = () => {
|
|
67
67
|
return true;
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
if (!config.drawVerticalLine) {
|
|
72
|
+
/**
|
|
73
|
+
* @returns {boolean}
|
|
74
|
+
*/
|
|
75
|
+
config.drawVerticalLine = () => {
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
if (config.singleLine === undefined) {
|
|
72
81
|
config.singleLine = false;
|
|
73
82
|
}
|
package/dist/makeStreamConfig.js
CHANGED
|
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
11
|
-
|
|
12
|
-
var _times2 = _interopRequireDefault(require("lodash/times"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
13
9
|
|
|
14
10
|
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
|
|
15
11
|
|
|
@@ -38,8 +34,8 @@ const makeBorder = (border = {}) => {
|
|
|
38
34
|
|
|
39
35
|
|
|
40
36
|
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
41
|
-
(0
|
|
42
|
-
if (
|
|
37
|
+
for (let index = 0; index < columnCount; index++) {
|
|
38
|
+
if (typeof columns[index] === 'undefined') {
|
|
43
39
|
columns[index] = {};
|
|
44
40
|
}
|
|
45
41
|
|
|
@@ -50,7 +46,8 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
|
50
46
|
truncate: Number.POSITIVE_INFINITY,
|
|
51
47
|
wrapWord: false
|
|
52
48
|
}, columnDefault, columns[index]);
|
|
53
|
-
}
|
|
49
|
+
}
|
|
50
|
+
|
|
54
51
|
return columns;
|
|
55
52
|
};
|
|
56
53
|
/**
|
|
@@ -81,7 +78,7 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
|
81
78
|
|
|
82
79
|
const makeStreamConfig = (userConfig = {}) => {
|
|
83
80
|
(0, _validateConfig.default)('streamConfig.json', userConfig);
|
|
84
|
-
const config = (0,
|
|
81
|
+
const config = (0, _lodash.default)(userConfig);
|
|
85
82
|
|
|
86
83
|
if (!config.columnDefault || !config.columnDefault.width) {
|
|
87
84
|
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
|
@@ -93,9 +90,18 @@ const makeStreamConfig = (userConfig = {}) => {
|
|
|
93
90
|
|
|
94
91
|
config.border = makeBorder(config.border);
|
|
95
92
|
config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
|
|
93
|
+
|
|
94
|
+
if (!config.drawVerticalLine) {
|
|
95
|
+
/**
|
|
96
|
+
* @returns {boolean}
|
|
97
|
+
*/
|
|
98
|
+
config.drawVerticalLine = () => {
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
return config;
|
|
97
104
|
};
|
|
98
105
|
|
|
99
106
|
var _default = makeStreamConfig;
|
|
100
|
-
exports.default = _default;
|
|
101
|
-
//# sourceMappingURL=makeStreamConfig.js.map
|
|
107
|
+
exports.default = _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
2
2
|
import getBorderCharacters from './getBorderCharacters';
|
|
3
3
|
import validateConfig from './validateConfig';
|
|
4
4
|
|
|
@@ -22,8 +22,8 @@ const makeBorder = (border = {}) => {
|
|
|
22
22
|
* @returns {object}
|
|
23
23
|
*/
|
|
24
24
|
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
25
|
-
|
|
26
|
-
if (
|
|
25
|
+
for (let index = 0; index < columnCount; index++) {
|
|
26
|
+
if (typeof columns[index] === 'undefined') {
|
|
27
27
|
columns[index] = {};
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -34,7 +34,7 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
|
34
34
|
truncate: Number.POSITIVE_INFINITY,
|
|
35
35
|
wrapWord: false,
|
|
36
36
|
}, columnDefault, columns[index]);
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
39
|
return columns;
|
|
40
40
|
};
|
|
@@ -66,7 +66,7 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
|
66
66
|
export default (userConfig = {}) => {
|
|
67
67
|
validateConfig('streamConfig.json', userConfig);
|
|
68
68
|
|
|
69
|
-
const config =
|
|
69
|
+
const config = cloneDeep(userConfig);
|
|
70
70
|
|
|
71
71
|
if (!config.columnDefault || !config.columnDefault.width) {
|
|
72
72
|
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
|
@@ -79,5 +79,14 @@ export default (userConfig = {}) => {
|
|
|
79
79
|
config.border = makeBorder(config.border);
|
|
80
80
|
config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
|
|
81
81
|
|
|
82
|
+
if (!config.drawVerticalLine) {
|
|
83
|
+
/**
|
|
84
|
+
* @returns {boolean}
|
|
85
|
+
*/
|
|
86
|
+
config.drawVerticalLine = () => {
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
82
91
|
return config;
|
|
83
92
|
};
|