table 6.0.9 → 6.3.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/README.md +53 -1
- package/dist/src/alignString.d.ts +6 -0
- package/dist/src/alignString.js +64 -0
- package/dist/src/alignTableData.d.ts +3 -0
- package/dist/src/alignTableData.js +21 -0
- package/dist/src/calculateCellHeight.d.ts +2 -0
- package/dist/src/calculateCellHeight.js +17 -0
- package/dist/src/calculateCellWidthIndex.d.ts +6 -0
- package/dist/src/calculateCellWidthIndex.js +17 -0
- package/dist/src/calculateMaximumColumnWidthIndex.d.ts +6 -0
- package/dist/src/calculateMaximumColumnWidthIndex.js +25 -0
- package/dist/src/calculateRowHeightIndex.d.ts +6 -0
- package/dist/src/calculateRowHeightIndex.js +30 -0
- package/dist/src/createStream.d.ts +3 -0
- package/dist/src/createStream.js +74 -0
- package/dist/src/drawBorder.d.ts +25 -0
- package/dist/src/drawBorder.js +55 -0
- package/dist/src/drawHorizontalContent.d.ts +11 -0
- package/dist/src/drawHorizontalContent.js +19 -0
- package/dist/src/drawRow.d.ts +7 -0
- package/dist/src/drawRow.js +17 -0
- package/dist/src/drawTable.d.ts +3 -0
- package/dist/src/drawTable.js +38 -0
- package/dist/src/getBorderCharacters.d.ts +3 -0
- package/dist/src/getBorderCharacters.js +83 -0
- package/dist/{index.js.flow → src/index.d.ts} +2 -6
- package/dist/src/index.js +24 -0
- package/dist/src/makeConfig.d.ts +8 -0
- package/dist/src/makeConfig.js +59 -0
- package/dist/src/makeStreamConfig.d.ts +8 -0
- package/dist/src/makeStreamConfig.js +60 -0
- package/dist/src/mapDataUsingRowHeightIndex.d.ts +3 -0
- package/dist/src/mapDataUsingRowHeightIndex.js +27 -0
- package/dist/src/padTableData.d.ts +3 -0
- package/dist/src/padTableData.js +11 -0
- package/dist/src/stringifyTableData.d.ts +3 -0
- package/dist/src/stringifyTableData.js +8 -0
- package/dist/src/table.d.ts +3 -0
- package/dist/src/table.js +28 -0
- package/dist/src/truncateTableData.d.ts +6 -0
- package/dist/src/truncateTableData.js +20 -0
- package/dist/src/types/api.d.ts +100 -0
- package/dist/src/types/api.js +3 -0
- package/dist/src/types/internal.d.ts +1 -0
- package/dist/src/types/internal.js +3 -0
- package/dist/src/validateConfig.d.ts +3 -0
- package/dist/src/validateConfig.js +27 -0
- package/dist/src/validateTableData.d.ts +2 -0
- package/dist/src/validateTableData.js +29 -0
- package/dist/{validators.js → src/validators.js} +54 -14
- package/dist/src/wrapCell.d.ts +9 -0
- package/dist/src/wrapCell.js +33 -0
- package/dist/src/wrapString.d.ts +10 -0
- package/dist/src/wrapString.js +25 -0
- package/dist/src/wrapWord.d.ts +2 -0
- package/dist/src/wrapWord.js +29 -0
- package/package.json +32 -25
- package/dist/alignString.js +0 -107
- package/dist/alignString.js.flow +0 -97
- package/dist/alignTableData.js +0 -34
- package/dist/alignTableData.js.flow +0 -21
- package/dist/calculateCellHeight.js +0 -37
- package/dist/calculateCellHeight.js.flow +0 -24
- package/dist/calculateCellWidthIndex.js +0 -27
- package/dist/calculateCellWidthIndex.js.flow +0 -17
- package/dist/calculateMaximumColumnWidthIndex.js +0 -36
- package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
- package/dist/calculateRowHeightIndex.js +0 -45
- package/dist/calculateRowHeightIndex.js.flow +0 -36
- package/dist/createStream.js +0 -124
- package/dist/createStream.js.flow +0 -125
- package/dist/drawBorder.js +0 -109
- package/dist/drawBorder.js.flow +0 -101
- package/dist/drawRow.js +0 -25
- package/dist/drawRow.js.flow +0 -15
- package/dist/drawTable.js +0 -58
- package/dist/drawTable.js.flow +0 -53
- package/dist/getBorderCharacters.js +0 -118
- package/dist/getBorderCharacters.js.flow +0 -120
- package/dist/index.js +0 -31
- package/dist/makeConfig.js +0 -91
- package/dist/makeConfig.js.flow +0 -76
- package/dist/makeStreamConfig.js +0 -97
- package/dist/makeStreamConfig.js.flow +0 -83
- package/dist/mapDataUsingRowHeightIndex.js +0 -41
- package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
- package/dist/padTableData.js +0 -23
- package/dist/padTableData.js.flow +0 -14
- package/dist/schemas/config.json +0 -23
- package/dist/schemas/shared.json +0 -98
- package/dist/schemas/streamConfig.json +0 -20
- package/dist/stringifyTableData.js +0 -21
- package/dist/stringifyTableData.js.flow +0 -11
- package/dist/table.js +0 -109
- package/dist/table.js.flow +0 -96
- package/dist/truncateTableData.js +0 -29
- package/dist/truncateTableData.js.flow +0 -17
- package/dist/validateConfig.js +0 -40
- package/dist/validateConfig.js.flow +0 -27
- package/dist/validateTableData.js +0 -54
- package/dist/validateTableData.js.flow +0 -44
- package/dist/wrapCell.js +0 -47
- package/dist/wrapCell.js.flow +0 -35
- package/dist/wrapString.js +0 -39
- package/dist/wrapString.js.flow +0 -29
- package/dist/wrapWord.js +0 -46
- package/dist/wrapWord.js.flow +0 -39
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _isBooleanObject = _interopRequireDefault(require("is-boolean-object"));
|
|
9
|
-
|
|
10
|
-
var _isNumberObject = _interopRequireDefault(require("is-number-object"));
|
|
11
|
-
|
|
12
|
-
var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Calculates the vertical row span index.
|
|
18
|
-
*
|
|
19
|
-
* @param {Array[]} rows
|
|
20
|
-
* @param {object} config
|
|
21
|
-
* @returns {number[]}
|
|
22
|
-
*/
|
|
23
|
-
const calculateRowHeightIndex = (rows, config) => {
|
|
24
|
-
const tableWidth = rows[0].length;
|
|
25
|
-
const rowSpanIndex = [];
|
|
26
|
-
rows.forEach(cells => {
|
|
27
|
-
const cellHeightIndex = new Array(tableWidth).fill(1);
|
|
28
|
-
cells.forEach((value, index1) => {
|
|
29
|
-
if (!(0, _isNumberObject.default)(config.columns[index1].width)) {
|
|
30
|
-
throw new TypeError('column[index].width must be a number.');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!(0, _isBooleanObject.default)(config.columns[index1].wrapWord)) {
|
|
34
|
-
throw new TypeError('column[index].wrapWord must be a boolean.');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
cellHeightIndex[index1] = (0, _calculateCellHeight.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
38
|
-
});
|
|
39
|
-
rowSpanIndex.push(Math.max(...cellHeightIndex));
|
|
40
|
-
});
|
|
41
|
-
return rowSpanIndex;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var _default = calculateRowHeightIndex;
|
|
45
|
-
exports.default = _default;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import isBoolean from 'is-boolean-object';
|
|
2
|
-
import isNumber from 'is-number-object';
|
|
3
|
-
import calculateCellHeight from './calculateCellHeight';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Calculates the vertical row span index.
|
|
7
|
-
*
|
|
8
|
-
* @param {Array[]} rows
|
|
9
|
-
* @param {object} config
|
|
10
|
-
* @returns {number[]}
|
|
11
|
-
*/
|
|
12
|
-
export default (rows, config) => {
|
|
13
|
-
const tableWidth = rows[0].length;
|
|
14
|
-
|
|
15
|
-
const rowSpanIndex = [];
|
|
16
|
-
|
|
17
|
-
rows.forEach((cells) => {
|
|
18
|
-
const cellHeightIndex = new Array(tableWidth).fill(1);
|
|
19
|
-
|
|
20
|
-
cells.forEach((value, index1) => {
|
|
21
|
-
if (!isNumber(config.columns[index1].width)) {
|
|
22
|
-
throw new TypeError('column[index].width must be a number.');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!isBoolean(config.columns[index1].wrapWord)) {
|
|
26
|
-
throw new TypeError('column[index].wrapWord must be a boolean.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
rowSpanIndex.push(Math.max(...cellHeightIndex));
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return rowSpanIndex;
|
|
36
|
-
};
|
package/dist/createStream.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _alignTableData = _interopRequireDefault(require("./alignTableData"));
|
|
9
|
-
|
|
10
|
-
var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex"));
|
|
11
|
-
|
|
12
|
-
var _drawBorder = require("./drawBorder");
|
|
13
|
-
|
|
14
|
-
var _drawRow = _interopRequireDefault(require("./drawRow"));
|
|
15
|
-
|
|
16
|
-
var _makeStreamConfig = _interopRequireDefault(require("./makeStreamConfig"));
|
|
17
|
-
|
|
18
|
-
var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex"));
|
|
19
|
-
|
|
20
|
-
var _padTableData = _interopRequireDefault(require("./padTableData"));
|
|
21
|
-
|
|
22
|
-
var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData"));
|
|
23
|
-
|
|
24
|
-
var _truncateTableData = _interopRequireDefault(require("./truncateTableData"));
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {Array} data
|
|
30
|
-
* @param {object} config
|
|
31
|
-
* @returns {Array}
|
|
32
|
-
*/
|
|
33
|
-
const prepareData = (data, config) => {
|
|
34
|
-
let rows;
|
|
35
|
-
rows = (0, _stringifyTableData.default)(data);
|
|
36
|
-
rows = (0, _truncateTableData.default)(data, config);
|
|
37
|
-
const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config);
|
|
38
|
-
rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config);
|
|
39
|
-
rows = (0, _alignTableData.default)(rows, config);
|
|
40
|
-
rows = (0, _padTableData.default)(rows, config);
|
|
41
|
-
return rows;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* @param {string[]} row
|
|
45
|
-
* @param {number[]} columnWidthIndex
|
|
46
|
-
* @param {object} config
|
|
47
|
-
* @returns {undefined}
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const create = (row, columnWidthIndex, config) => {
|
|
52
|
-
const rows = prepareData([row], config);
|
|
53
|
-
const body = rows.map(literalRow => {
|
|
54
|
-
return (0, _drawRow.default)(literalRow, config.border);
|
|
55
|
-
}).join('');
|
|
56
|
-
let output;
|
|
57
|
-
output = '';
|
|
58
|
-
output += (0, _drawBorder.drawBorderTop)(columnWidthIndex, config.border);
|
|
59
|
-
output += body;
|
|
60
|
-
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border);
|
|
61
|
-
output = output.trimEnd();
|
|
62
|
-
process.stdout.write(output);
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* @param {string[]} row
|
|
66
|
-
* @param {number[]} columnWidthIndex
|
|
67
|
-
* @param {object} config
|
|
68
|
-
* @returns {undefined}
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const append = (row, columnWidthIndex, config) => {
|
|
73
|
-
const rows = prepareData([row], config);
|
|
74
|
-
const body = rows.map(literalRow => {
|
|
75
|
-
return (0, _drawRow.default)(literalRow, config.border);
|
|
76
|
-
}).join('');
|
|
77
|
-
let output = '';
|
|
78
|
-
const bottom = (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border);
|
|
79
|
-
|
|
80
|
-
if (bottom !== '\n') {
|
|
81
|
-
output = '\r\u001B[K';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
output += (0, _drawBorder.drawBorderJoin)(columnWidthIndex, config.border);
|
|
85
|
-
output += body;
|
|
86
|
-
output += bottom;
|
|
87
|
-
output = output.trimEnd();
|
|
88
|
-
process.stdout.write(output);
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* @param {object} userConfig
|
|
92
|
-
* @returns {object}
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const createStream = (userConfig = {}) => {
|
|
97
|
-
const config = (0, _makeStreamConfig.default)(userConfig);
|
|
98
|
-
const columnWidthIndex = Object.values(config.columns).map(column => {
|
|
99
|
-
return column.width + column.paddingLeft + column.paddingRight;
|
|
100
|
-
});
|
|
101
|
-
let empty;
|
|
102
|
-
empty = true;
|
|
103
|
-
return {
|
|
104
|
-
/**
|
|
105
|
-
* @param {string[]} row
|
|
106
|
-
* @returns {undefined}
|
|
107
|
-
*/
|
|
108
|
-
write: row => {
|
|
109
|
-
if (row.length !== config.columnCount) {
|
|
110
|
-
throw new Error('Row cell count does not match the config.columnCount.');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (empty) {
|
|
114
|
-
empty = false;
|
|
115
|
-
return create(row, columnWidthIndex, config);
|
|
116
|
-
} else {
|
|
117
|
-
return append(row, columnWidthIndex, config);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var _default = createStream;
|
|
124
|
-
exports.default = _default;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import alignTableData from './alignTableData';
|
|
2
|
-
import calculateRowHeightIndex from './calculateRowHeightIndex';
|
|
3
|
-
import {
|
|
4
|
-
drawBorderBottom,
|
|
5
|
-
drawBorderJoin,
|
|
6
|
-
drawBorderTop,
|
|
7
|
-
} from './drawBorder';
|
|
8
|
-
import drawRow from './drawRow';
|
|
9
|
-
import makeStreamConfig from './makeStreamConfig';
|
|
10
|
-
import mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';
|
|
11
|
-
import padTableData from './padTableData';
|
|
12
|
-
import stringifyTableData from './stringifyTableData';
|
|
13
|
-
import truncateTableData from './truncateTableData';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {Array} data
|
|
17
|
-
* @param {object} config
|
|
18
|
-
* @returns {Array}
|
|
19
|
-
*/
|
|
20
|
-
const prepareData = (data, config) => {
|
|
21
|
-
let rows;
|
|
22
|
-
|
|
23
|
-
rows = stringifyTableData(data);
|
|
24
|
-
|
|
25
|
-
rows = truncateTableData(data, config);
|
|
26
|
-
|
|
27
|
-
const rowHeightIndex = calculateRowHeightIndex(rows, config);
|
|
28
|
-
|
|
29
|
-
rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);
|
|
30
|
-
rows = alignTableData(rows, config);
|
|
31
|
-
rows = padTableData(rows, config);
|
|
32
|
-
|
|
33
|
-
return rows;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {string[]} row
|
|
38
|
-
* @param {number[]} columnWidthIndex
|
|
39
|
-
* @param {object} config
|
|
40
|
-
* @returns {undefined}
|
|
41
|
-
*/
|
|
42
|
-
const create = (row, columnWidthIndex, config) => {
|
|
43
|
-
const rows = prepareData([row], config);
|
|
44
|
-
|
|
45
|
-
const body = rows.map((literalRow) => {
|
|
46
|
-
return drawRow(literalRow, config.border);
|
|
47
|
-
}).join('');
|
|
48
|
-
|
|
49
|
-
let output;
|
|
50
|
-
|
|
51
|
-
output = '';
|
|
52
|
-
|
|
53
|
-
output += drawBorderTop(columnWidthIndex, config.border);
|
|
54
|
-
output += body;
|
|
55
|
-
output += drawBorderBottom(columnWidthIndex, config.border);
|
|
56
|
-
|
|
57
|
-
output = output.trimEnd();
|
|
58
|
-
|
|
59
|
-
process.stdout.write(output);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @param {string[]} row
|
|
64
|
-
* @param {number[]} columnWidthIndex
|
|
65
|
-
* @param {object} config
|
|
66
|
-
* @returns {undefined}
|
|
67
|
-
*/
|
|
68
|
-
const append = (row, columnWidthIndex, config) => {
|
|
69
|
-
const rows = prepareData([row], config);
|
|
70
|
-
|
|
71
|
-
const body = rows.map((literalRow) => {
|
|
72
|
-
return drawRow(literalRow, config.border);
|
|
73
|
-
}).join('');
|
|
74
|
-
|
|
75
|
-
let output = '';
|
|
76
|
-
const bottom = drawBorderBottom(columnWidthIndex, config.border);
|
|
77
|
-
|
|
78
|
-
if (bottom !== '\n') {
|
|
79
|
-
output = '\r\u001B[K';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
output += drawBorderJoin(columnWidthIndex, config.border);
|
|
83
|
-
output += body;
|
|
84
|
-
output += bottom;
|
|
85
|
-
|
|
86
|
-
output = output.trimEnd();
|
|
87
|
-
|
|
88
|
-
process.stdout.write(output);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @param {object} userConfig
|
|
93
|
-
* @returns {object}
|
|
94
|
-
*/
|
|
95
|
-
export default (userConfig = {}) => {
|
|
96
|
-
const config = makeStreamConfig(userConfig);
|
|
97
|
-
|
|
98
|
-
const columnWidthIndex = Object.values(config.columns).map((column) => {
|
|
99
|
-
return column.width + column.paddingLeft + column.paddingRight;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
let empty;
|
|
103
|
-
|
|
104
|
-
empty = true;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
/**
|
|
108
|
-
* @param {string[]} row
|
|
109
|
-
* @returns {undefined}
|
|
110
|
-
*/
|
|
111
|
-
write: (row) => {
|
|
112
|
-
if (row.length !== config.columnCount) {
|
|
113
|
-
throw new Error('Row cell count does not match the config.columnCount.');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (empty) {
|
|
117
|
-
empty = false;
|
|
118
|
-
|
|
119
|
-
return create(row, columnWidthIndex, config);
|
|
120
|
-
} else {
|
|
121
|
-
return append(row, columnWidthIndex, config);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
};
|
package/dist/drawBorder.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef drawBorder~parts
|
|
10
|
-
* @property {string} left
|
|
11
|
-
* @property {string} right
|
|
12
|
-
* @property {string} body
|
|
13
|
-
* @property {string} join
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {number[]} columnSizeIndex
|
|
18
|
-
* @param {drawBorder~parts} parts
|
|
19
|
-
* @returns {string}
|
|
20
|
-
*/
|
|
21
|
-
const drawBorder = (columnSizeIndex, parts) => {
|
|
22
|
-
const columns = columnSizeIndex.map(size => {
|
|
23
|
-
return parts.body.repeat(size);
|
|
24
|
-
}).join(parts.join);
|
|
25
|
-
return parts.left + columns + parts.right + '\n';
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* @typedef drawBorderTop~parts
|
|
29
|
-
* @property {string} topLeft
|
|
30
|
-
* @property {string} topRight
|
|
31
|
-
* @property {string} topBody
|
|
32
|
-
* @property {string} topJoin
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {number[]} columnSizeIndex
|
|
37
|
-
* @param {drawBorderTop~parts} parts
|
|
38
|
-
* @returns {string}
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
exports.drawBorder = drawBorder;
|
|
43
|
-
|
|
44
|
-
const drawBorderTop = (columnSizeIndex, parts) => {
|
|
45
|
-
const border = drawBorder(columnSizeIndex, {
|
|
46
|
-
body: parts.topBody,
|
|
47
|
-
join: parts.topJoin,
|
|
48
|
-
left: parts.topLeft,
|
|
49
|
-
right: parts.topRight
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (border === '\n') {
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return border;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* @typedef drawBorderJoin~parts
|
|
60
|
-
* @property {string} joinLeft
|
|
61
|
-
* @property {string} joinRight
|
|
62
|
-
* @property {string} joinBody
|
|
63
|
-
* @property {string} joinJoin
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @param {number[]} columnSizeIndex
|
|
68
|
-
* @param {drawBorderJoin~parts} parts
|
|
69
|
-
* @returns {string}
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
exports.drawBorderTop = drawBorderTop;
|
|
74
|
-
|
|
75
|
-
const drawBorderJoin = (columnSizeIndex, parts) => {
|
|
76
|
-
return drawBorder(columnSizeIndex, {
|
|
77
|
-
body: parts.joinBody,
|
|
78
|
-
join: parts.joinJoin,
|
|
79
|
-
left: parts.joinLeft,
|
|
80
|
-
right: parts.joinRight
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* @typedef drawBorderBottom~parts
|
|
85
|
-
* @property {string} topLeft
|
|
86
|
-
* @property {string} topRight
|
|
87
|
-
* @property {string} topBody
|
|
88
|
-
* @property {string} topJoin
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @param {number[]} columnSizeIndex
|
|
93
|
-
* @param {drawBorderBottom~parts} parts
|
|
94
|
-
* @returns {string}
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
exports.drawBorderJoin = drawBorderJoin;
|
|
99
|
-
|
|
100
|
-
const drawBorderBottom = (columnSizeIndex, parts) => {
|
|
101
|
-
return drawBorder(columnSizeIndex, {
|
|
102
|
-
body: parts.bottomBody,
|
|
103
|
-
join: parts.bottomJoin,
|
|
104
|
-
left: parts.bottomLeft,
|
|
105
|
-
right: parts.bottomRight
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.drawBorderBottom = drawBorderBottom;
|
package/dist/drawBorder.js.flow
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef drawBorder~parts
|
|
3
|
-
* @property {string} left
|
|
4
|
-
* @property {string} right
|
|
5
|
-
* @property {string} body
|
|
6
|
-
* @property {string} join
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {number[]} columnSizeIndex
|
|
11
|
-
* @param {drawBorder~parts} parts
|
|
12
|
-
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
const drawBorder = (columnSizeIndex, parts) => {
|
|
15
|
-
const columns = columnSizeIndex
|
|
16
|
-
.map((size) => {
|
|
17
|
-
return parts.body.repeat(size);
|
|
18
|
-
})
|
|
19
|
-
.join(parts.join);
|
|
20
|
-
|
|
21
|
-
return parts.left + columns + parts.right + '\n';
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @typedef drawBorderTop~parts
|
|
26
|
-
* @property {string} topLeft
|
|
27
|
-
* @property {string} topRight
|
|
28
|
-
* @property {string} topBody
|
|
29
|
-
* @property {string} topJoin
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {number[]} columnSizeIndex
|
|
34
|
-
* @param {drawBorderTop~parts} parts
|
|
35
|
-
* @returns {string}
|
|
36
|
-
*/
|
|
37
|
-
const drawBorderTop = (columnSizeIndex, parts) => {
|
|
38
|
-
const border = drawBorder(columnSizeIndex, {
|
|
39
|
-
body: parts.topBody,
|
|
40
|
-
join: parts.topJoin,
|
|
41
|
-
left: parts.topLeft,
|
|
42
|
-
right: parts.topRight,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (border === '\n') {
|
|
46
|
-
return '';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return border;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @typedef drawBorderJoin~parts
|
|
54
|
-
* @property {string} joinLeft
|
|
55
|
-
* @property {string} joinRight
|
|
56
|
-
* @property {string} joinBody
|
|
57
|
-
* @property {string} joinJoin
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @param {number[]} columnSizeIndex
|
|
62
|
-
* @param {drawBorderJoin~parts} parts
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
const drawBorderJoin = (columnSizeIndex, parts) => {
|
|
66
|
-
return drawBorder(columnSizeIndex, {
|
|
67
|
-
body: parts.joinBody,
|
|
68
|
-
join: parts.joinJoin,
|
|
69
|
-
left: parts.joinLeft,
|
|
70
|
-
right: parts.joinRight,
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @typedef drawBorderBottom~parts
|
|
76
|
-
* @property {string} topLeft
|
|
77
|
-
* @property {string} topRight
|
|
78
|
-
* @property {string} topBody
|
|
79
|
-
* @property {string} topJoin
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {number[]} columnSizeIndex
|
|
84
|
-
* @param {drawBorderBottom~parts} parts
|
|
85
|
-
* @returns {string}
|
|
86
|
-
*/
|
|
87
|
-
const drawBorderBottom = (columnSizeIndex, parts) => {
|
|
88
|
-
return drawBorder(columnSizeIndex, {
|
|
89
|
-
body: parts.bottomBody,
|
|
90
|
-
join: parts.bottomJoin,
|
|
91
|
-
left: parts.bottomLeft,
|
|
92
|
-
right: parts.bottomRight,
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
drawBorder,
|
|
98
|
-
drawBorderBottom,
|
|
99
|
-
drawBorderJoin,
|
|
100
|
-
drawBorderTop,
|
|
101
|
-
};
|
package/dist/drawRow.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {object} drawRow~border
|
|
10
|
-
* @property {string} bodyLeft
|
|
11
|
-
* @property {string} bodyRight
|
|
12
|
-
* @property {string} bodyJoin
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {number[]} columns
|
|
17
|
-
* @param {drawRow~border} border
|
|
18
|
-
* @returns {string}
|
|
19
|
-
*/
|
|
20
|
-
const drawRow = (columns, border) => {
|
|
21
|
-
return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n';
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
var _default = drawRow;
|
|
25
|
-
exports.default = _default;
|
package/dist/drawRow.js.flow
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} drawRow~border
|
|
3
|
-
* @property {string} bodyLeft
|
|
4
|
-
* @property {string} bodyRight
|
|
5
|
-
* @property {string} bodyJoin
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {number[]} columns
|
|
10
|
-
* @param {drawRow~border} border
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
|
-
export default (columns, border) => {
|
|
14
|
-
return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n';
|
|
15
|
-
};
|
package/dist/drawTable.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _drawBorder = require("./drawBorder");
|
|
9
|
-
|
|
10
|
-
var _drawRow = _interopRequireDefault(require("./drawRow"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {Array} rows
|
|
16
|
-
* @param {object} border
|
|
17
|
-
* @param {Array} columnSizeIndex
|
|
18
|
-
* @param {Array} rowSpanIndex
|
|
19
|
-
* @param {Function} drawHorizontalLine
|
|
20
|
-
* @param {boolean} singleLine
|
|
21
|
-
* @returns {string}
|
|
22
|
-
*/
|
|
23
|
-
const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine, singleLine) => {
|
|
24
|
-
let output;
|
|
25
|
-
let realRowIndex;
|
|
26
|
-
let rowHeight;
|
|
27
|
-
const rowCount = rows.length;
|
|
28
|
-
realRowIndex = 0;
|
|
29
|
-
output = '';
|
|
30
|
-
|
|
31
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
32
|
-
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
rows.forEach((row, index0) => {
|
|
36
|
-
output += (0, _drawRow.default)(row, border);
|
|
37
|
-
|
|
38
|
-
if (!rowHeight) {
|
|
39
|
-
rowHeight = rowSpanIndex[realRowIndex];
|
|
40
|
-
realRowIndex++;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
rowHeight--;
|
|
44
|
-
|
|
45
|
-
if (!singleLine && rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
|
|
46
|
-
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
51
|
-
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return output;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var _default = drawTable;
|
|
58
|
-
exports.default = _default;
|
package/dist/drawTable.js.flow
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
drawBorderTop,
|
|
3
|
-
drawBorderJoin,
|
|
4
|
-
drawBorderBottom,
|
|
5
|
-
} from './drawBorder';
|
|
6
|
-
import drawRow from './drawRow';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {Array} rows
|
|
10
|
-
* @param {object} border
|
|
11
|
-
* @param {Array} columnSizeIndex
|
|
12
|
-
* @param {Array} rowSpanIndex
|
|
13
|
-
* @param {Function} drawHorizontalLine
|
|
14
|
-
* @param {boolean} singleLine
|
|
15
|
-
* @returns {string}
|
|
16
|
-
*/
|
|
17
|
-
export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine, singleLine) => {
|
|
18
|
-
let output;
|
|
19
|
-
let realRowIndex;
|
|
20
|
-
let rowHeight;
|
|
21
|
-
|
|
22
|
-
const rowCount = rows.length;
|
|
23
|
-
|
|
24
|
-
realRowIndex = 0;
|
|
25
|
-
|
|
26
|
-
output = '';
|
|
27
|
-
|
|
28
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
29
|
-
output += drawBorderTop(columnSizeIndex, border);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
rows.forEach((row, index0) => {
|
|
33
|
-
output += drawRow(row, border);
|
|
34
|
-
|
|
35
|
-
if (!rowHeight) {
|
|
36
|
-
rowHeight = rowSpanIndex[realRowIndex];
|
|
37
|
-
|
|
38
|
-
realRowIndex++;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
rowHeight--;
|
|
42
|
-
|
|
43
|
-
if (!singleLine && rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
|
|
44
|
-
output += drawBorderJoin(columnSizeIndex, border);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
49
|
-
output += drawBorderBottom(columnSizeIndex, border);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return output;
|
|
53
|
-
};
|