table 6.2.0 → 6.3.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 +1 -1
- package/dist/src/alignString.js +64 -0
- package/dist/src/alignTableData.js +21 -0
- package/dist/src/calculateCellHeight.js +17 -0
- package/dist/src/calculateCellWidthIndex.js +17 -0
- package/dist/src/calculateMaximumColumnWidthIndex.js +25 -0
- package/dist/src/calculateRowHeightIndex.js +30 -0
- package/dist/src/createStream.js +74 -0
- package/dist/src/drawBorder.js +55 -0
- package/dist/src/drawHorizontalContent.js +19 -0
- package/dist/src/drawRow.js +17 -0
- package/dist/src/drawTable.js +38 -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.js +59 -0
- package/dist/src/makeStreamConfig.js +60 -0
- package/dist/src/mapDataUsingRowHeightIndex.js +27 -0
- package/dist/src/padTableData.js +11 -0
- package/dist/src/stringifyTableData.js +8 -0
- package/dist/src/table.js +28 -0
- package/dist/src/truncateTableData.js +20 -0
- package/dist/src/types/api.d.ts +99 -0
- package/dist/src/types/api.js +3 -0
- package/dist/src/types/internal.js +3 -0
- package/dist/src/validateConfig.js +27 -0
- package/dist/src/validateTableData.js +29 -0
- package/dist/{validators.js → src/validators.js} +0 -0
- package/dist/src/wrapCell.js +33 -0
- package/dist/src/wrapString.js +25 -0
- package/dist/src/wrapWord.js +29 -0
- package/package.json +33 -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 -115
- package/dist/drawBorder.js.flow +0 -89
- package/dist/drawHorizontalContent.js +0 -41
- package/dist/drawHorizontalContent.js.flow +0 -31
- package/dist/drawRow.js +0 -41
- package/dist/drawRow.js.flow +0 -29
- package/dist/drawTable.js +0 -60
- package/dist/drawTable.js.flow +0 -64
- package/dist/getBorderCharacters.js +0 -118
- package/dist/getBorderCharacters.js.flow +0 -120
- package/dist/index.js +0 -31
- package/dist/makeConfig.js +0 -100
- package/dist/makeConfig.js.flow +0 -85
- package/dist/makeStreamConfig.js +0 -107
- package/dist/makeStreamConfig.js.flow +0 -92
- 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 -26
- package/dist/schemas/shared.json +0 -98
- package/dist/schemas/streamConfig.json +0 -23
- package/dist/stringifyTableData.js +0 -21
- package/dist/stringifyTableData.js.flow +0 -11
- package/dist/table.js +0 -121
- package/dist/table.js.flow +0 -108
- package/dist/truncateTableData.js +0 -30
- package/dist/truncateTableData.js.flow +0 -18
- 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
package/dist/makeConfig.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
9
|
-
|
|
10
|
-
var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));
|
|
11
|
-
|
|
12
|
-
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
|
|
13
|
-
|
|
14
|
-
var _validateConfig = _interopRequireDefault(require("./validateConfig"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
20
|
-
*
|
|
21
|
-
* @param {object} border
|
|
22
|
-
* @returns {object}
|
|
23
|
-
*/
|
|
24
|
-
const makeBorder = (border = {}) => {
|
|
25
|
-
return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Creates a configuration for every column using default
|
|
29
|
-
* values for the missing configuration properties.
|
|
30
|
-
*
|
|
31
|
-
* @param {Array[]} rows
|
|
32
|
-
* @param {object} columns
|
|
33
|
-
* @param {object} columnDefault
|
|
34
|
-
* @returns {object}
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
39
|
-
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
|
|
40
|
-
|
|
41
|
-
for (let index = 0; index < rows[0].length; index++) {
|
|
42
|
-
if (typeof columns[index] === 'undefined') {
|
|
43
|
-
columns[index] = {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
columns[index] = Object.assign({
|
|
47
|
-
alignment: 'left',
|
|
48
|
-
paddingLeft: 1,
|
|
49
|
-
paddingRight: 1,
|
|
50
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
51
|
-
width: maximumColumnWidthIndex[index],
|
|
52
|
-
wrapWord: false
|
|
53
|
-
}, columnDefault, columns[index]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return columns;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Makes a new configuration object out of the userConfig object
|
|
60
|
-
* using default values for the missing configuration properties.
|
|
61
|
-
*
|
|
62
|
-
* @param {Array[]} rows
|
|
63
|
-
* @param {object} userConfig
|
|
64
|
-
* @returns {object}
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const makeConfig = (rows, userConfig = {}) => {
|
|
69
|
-
(0, _validateConfig.default)('config.json', userConfig);
|
|
70
|
-
const config = (0, _lodash.default)(userConfig);
|
|
71
|
-
config.border = makeBorder(config.border);
|
|
72
|
-
config.columns = makeColumns(rows, config.columns, config.columnDefault);
|
|
73
|
-
|
|
74
|
-
if (!config.drawHorizontalLine) {
|
|
75
|
-
/**
|
|
76
|
-
* @returns {boolean}
|
|
77
|
-
*/
|
|
78
|
-
config.drawHorizontalLine = () => {
|
|
79
|
-
return true;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!config.drawVerticalLine) {
|
|
84
|
-
/**
|
|
85
|
-
* @returns {boolean}
|
|
86
|
-
*/
|
|
87
|
-
config.drawVerticalLine = () => {
|
|
88
|
-
return true;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (config.singleLine === undefined) {
|
|
93
|
-
config.singleLine = false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return config;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
var _default = makeConfig;
|
|
100
|
-
exports.default = _default;
|
package/dist/makeConfig.js.flow
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
2
|
-
import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';
|
|
3
|
-
import getBorderCharacters from './getBorderCharacters';
|
|
4
|
-
import validateConfig from './validateConfig';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
8
|
-
*
|
|
9
|
-
* @param {object} border
|
|
10
|
-
* @returns {object}
|
|
11
|
-
*/
|
|
12
|
-
const makeBorder = (border = {}) => {
|
|
13
|
-
return Object.assign({}, getBorderCharacters('honeywell'), border);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates a configuration for every column using default
|
|
18
|
-
* values for the missing configuration properties.
|
|
19
|
-
*
|
|
20
|
-
* @param {Array[]} rows
|
|
21
|
-
* @param {object} columns
|
|
22
|
-
* @param {object} columnDefault
|
|
23
|
-
* @returns {object}
|
|
24
|
-
*/
|
|
25
|
-
const makeColumns = (rows, columns = {}, columnDefault = {}) => {
|
|
26
|
-
const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);
|
|
27
|
-
|
|
28
|
-
for (let index = 0; index < rows[0].length; index++) {
|
|
29
|
-
if (typeof columns[index] === 'undefined') {
|
|
30
|
-
columns[index] = {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
columns[index] = Object.assign({
|
|
34
|
-
alignment: 'left',
|
|
35
|
-
paddingLeft: 1,
|
|
36
|
-
paddingRight: 1,
|
|
37
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
38
|
-
width: maximumColumnWidthIndex[index],
|
|
39
|
-
wrapWord: false,
|
|
40
|
-
}, columnDefault, columns[index]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return columns;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Makes a new configuration object out of the userConfig object
|
|
48
|
-
* using default values for the missing configuration properties.
|
|
49
|
-
*
|
|
50
|
-
* @param {Array[]} rows
|
|
51
|
-
* @param {object} userConfig
|
|
52
|
-
* @returns {object}
|
|
53
|
-
*/
|
|
54
|
-
export default (rows, userConfig = {}) => {
|
|
55
|
-
validateConfig('config.json', userConfig);
|
|
56
|
-
|
|
57
|
-
const config = cloneDeep(userConfig);
|
|
58
|
-
|
|
59
|
-
config.border = makeBorder(config.border);
|
|
60
|
-
config.columns = makeColumns(rows, config.columns, config.columnDefault);
|
|
61
|
-
|
|
62
|
-
if (!config.drawHorizontalLine) {
|
|
63
|
-
/**
|
|
64
|
-
* @returns {boolean}
|
|
65
|
-
*/
|
|
66
|
-
config.drawHorizontalLine = () => {
|
|
67
|
-
return true;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!config.drawVerticalLine) {
|
|
72
|
-
/**
|
|
73
|
-
* @returns {boolean}
|
|
74
|
-
*/
|
|
75
|
-
config.drawVerticalLine = () => {
|
|
76
|
-
return true;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (config.singleLine === undefined) {
|
|
81
|
-
config.singleLine = false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return config;
|
|
85
|
-
};
|
package/dist/makeStreamConfig.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
9
|
-
|
|
10
|
-
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
|
|
11
|
-
|
|
12
|
-
var _validateConfig = _interopRequireDefault(require("./validateConfig"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
18
|
-
*
|
|
19
|
-
* @param {object} border
|
|
20
|
-
* @returns {object}
|
|
21
|
-
*/
|
|
22
|
-
const makeBorder = (border = {}) => {
|
|
23
|
-
return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Creates a configuration for every column using default
|
|
27
|
-
* values for the missing configuration properties.
|
|
28
|
-
*
|
|
29
|
-
* @param {number} columnCount
|
|
30
|
-
* @param {object} columns
|
|
31
|
-
* @param {object} columnDefault
|
|
32
|
-
* @returns {object}
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
37
|
-
for (let index = 0; index < columnCount; index++) {
|
|
38
|
-
if (typeof columns[index] === 'undefined') {
|
|
39
|
-
columns[index] = {};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
columns[index] = Object.assign({
|
|
43
|
-
alignment: 'left',
|
|
44
|
-
paddingLeft: 1,
|
|
45
|
-
paddingRight: 1,
|
|
46
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
47
|
-
wrapWord: false
|
|
48
|
-
}, columnDefault, columns[index]);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return columns;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {object} columnConfig
|
|
55
|
-
* @property {string} alignment
|
|
56
|
-
* @property {number} width
|
|
57
|
-
* @property {number} truncate
|
|
58
|
-
* @property {number} paddingLeft
|
|
59
|
-
* @property {number} paddingRight
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @typedef {object} streamConfig
|
|
64
|
-
* @property {columnConfig} columnDefault
|
|
65
|
-
* @property {object} border
|
|
66
|
-
* @property {columnConfig[]}
|
|
67
|
-
* @property {number} columnCount Number of columns in the table (required).
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Makes a new configuration object out of the userConfig object
|
|
72
|
-
* using default values for the missing configuration properties.
|
|
73
|
-
*
|
|
74
|
-
* @param {streamConfig} userConfig
|
|
75
|
-
* @returns {object}
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const makeStreamConfig = (userConfig = {}) => {
|
|
80
|
-
(0, _validateConfig.default)('streamConfig.json', userConfig);
|
|
81
|
-
const config = (0, _lodash.default)(userConfig);
|
|
82
|
-
|
|
83
|
-
if (!config.columnDefault || !config.columnDefault.width) {
|
|
84
|
-
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!config.columnCount) {
|
|
88
|
-
throw new Error('Must provide config.columnCount.');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
config.border = makeBorder(config.border);
|
|
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
|
-
|
|
103
|
-
return config;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
var _default = makeStreamConfig;
|
|
107
|
-
exports.default = _default;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
2
|
-
import getBorderCharacters from './getBorderCharacters';
|
|
3
|
-
import validateConfig from './validateConfig';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
7
|
-
*
|
|
8
|
-
* @param {object} border
|
|
9
|
-
* @returns {object}
|
|
10
|
-
*/
|
|
11
|
-
const makeBorder = (border = {}) => {
|
|
12
|
-
return Object.assign({}, getBorderCharacters('honeywell'), border);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Creates a configuration for every column using default
|
|
17
|
-
* values for the missing configuration properties.
|
|
18
|
-
*
|
|
19
|
-
* @param {number} columnCount
|
|
20
|
-
* @param {object} columns
|
|
21
|
-
* @param {object} columnDefault
|
|
22
|
-
* @returns {object}
|
|
23
|
-
*/
|
|
24
|
-
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
|
|
25
|
-
for (let index = 0; index < columnCount; index++) {
|
|
26
|
-
if (typeof columns[index] === 'undefined') {
|
|
27
|
-
columns[index] = {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
columns[index] = Object.assign({
|
|
31
|
-
alignment: 'left',
|
|
32
|
-
paddingLeft: 1,
|
|
33
|
-
paddingRight: 1,
|
|
34
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
35
|
-
wrapWord: false,
|
|
36
|
-
}, columnDefault, columns[index]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return columns;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {object} columnConfig
|
|
44
|
-
* @property {string} alignment
|
|
45
|
-
* @property {number} width
|
|
46
|
-
* @property {number} truncate
|
|
47
|
-
* @property {number} paddingLeft
|
|
48
|
-
* @property {number} paddingRight
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @typedef {object} streamConfig
|
|
53
|
-
* @property {columnConfig} columnDefault
|
|
54
|
-
* @property {object} border
|
|
55
|
-
* @property {columnConfig[]}
|
|
56
|
-
* @property {number} columnCount Number of columns in the table (required).
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Makes a new configuration object out of the userConfig object
|
|
61
|
-
* using default values for the missing configuration properties.
|
|
62
|
-
*
|
|
63
|
-
* @param {streamConfig} userConfig
|
|
64
|
-
* @returns {object}
|
|
65
|
-
*/
|
|
66
|
-
export default (userConfig = {}) => {
|
|
67
|
-
validateConfig('streamConfig.json', userConfig);
|
|
68
|
-
|
|
69
|
-
const config = cloneDeep(userConfig);
|
|
70
|
-
|
|
71
|
-
if (!config.columnDefault || !config.columnDefault.width) {
|
|
72
|
-
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!config.columnCount) {
|
|
76
|
-
throw new Error('Must provide config.columnCount.');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
config.border = makeBorder(config.border);
|
|
80
|
-
config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
|
|
81
|
-
|
|
82
|
-
if (!config.drawVerticalLine) {
|
|
83
|
-
/**
|
|
84
|
-
* @returns {boolean}
|
|
85
|
-
*/
|
|
86
|
-
config.drawVerticalLine = () => {
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return config;
|
|
92
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash.flatten"));
|
|
9
|
-
|
|
10
|
-
var _wrapCell = _interopRequireDefault(require("./wrapCell"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {Array} unmappedRows
|
|
16
|
-
* @param {number[]} rowHeightIndex
|
|
17
|
-
* @param {object} config
|
|
18
|
-
* @returns {Array}
|
|
19
|
-
*/
|
|
20
|
-
const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
|
|
21
|
-
const tableWidth = unmappedRows[0].length;
|
|
22
|
-
const mappedRows = unmappedRows.map((cells, index0) => {
|
|
23
|
-
const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
|
|
24
|
-
return new Array(tableWidth).fill('');
|
|
25
|
-
}); // rowHeight
|
|
26
|
-
// [{row index within rowSaw; index2}]
|
|
27
|
-
// [{cell index within a virtual row; index1}]
|
|
28
|
-
|
|
29
|
-
cells.forEach((value, index1) => {
|
|
30
|
-
const cellLines = (0, _wrapCell.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
31
|
-
cellLines.forEach((cellLine, index2) => {
|
|
32
|
-
rowHeight[index2][index1] = cellLine;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
return rowHeight;
|
|
36
|
-
});
|
|
37
|
-
return (0, _lodash.default)(mappedRows);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var _default = mapDataUsingRowHeightIndex;
|
|
41
|
-
exports.default = _default;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import flatten from 'lodash.flatten';
|
|
2
|
-
import wrapCell from './wrapCell';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {Array} unmappedRows
|
|
6
|
-
* @param {number[]} rowHeightIndex
|
|
7
|
-
* @param {object} config
|
|
8
|
-
* @returns {Array}
|
|
9
|
-
*/
|
|
10
|
-
export default (unmappedRows, rowHeightIndex, config) => {
|
|
11
|
-
const tableWidth = unmappedRows[0].length;
|
|
12
|
-
|
|
13
|
-
const mappedRows = unmappedRows.map((cells, index0) => {
|
|
14
|
-
const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
|
|
15
|
-
return new Array(tableWidth).fill('');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// rowHeight
|
|
19
|
-
// [{row index within rowSaw; index2}]
|
|
20
|
-
// [{cell index within a virtual row; index1}]
|
|
21
|
-
|
|
22
|
-
cells.forEach((value, index1) => {
|
|
23
|
-
const cellLines = wrapCell(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
24
|
-
|
|
25
|
-
cellLines.forEach((cellLine, index2) => {
|
|
26
|
-
rowHeight[index2][index1] = cellLine;
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return rowHeight;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return flatten(mappedRows);
|
|
34
|
-
};
|
package/dist/padTableData.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {table~row[]} rows
|
|
10
|
-
* @param {object} config
|
|
11
|
-
* @returns {table~row[]}
|
|
12
|
-
*/
|
|
13
|
-
const padTableData = (rows, config) => {
|
|
14
|
-
return rows.map(cells => {
|
|
15
|
-
return cells.map((value, index1) => {
|
|
16
|
-
const column = config.columns[index1];
|
|
17
|
-
return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var _default = padTableData;
|
|
23
|
-
exports.default = _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {table~row[]} rows
|
|
3
|
-
* @param {object} config
|
|
4
|
-
* @returns {table~row[]}
|
|
5
|
-
*/
|
|
6
|
-
export default (rows, config) => {
|
|
7
|
-
return rows.map((cells) => {
|
|
8
|
-
return cells.map((value, index1) => {
|
|
9
|
-
const column = config.columns[index1];
|
|
10
|
-
|
|
11
|
-
return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
};
|
package/dist/schemas/config.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "config.json",
|
|
3
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"border": {
|
|
7
|
-
"$ref": "shared.json#/definitions/borders"
|
|
8
|
-
},
|
|
9
|
-
"columns": {
|
|
10
|
-
"$ref": "shared.json#/definitions/columns"
|
|
11
|
-
},
|
|
12
|
-
"columnDefault": {
|
|
13
|
-
"$ref": "shared.json#/definitions/column"
|
|
14
|
-
},
|
|
15
|
-
"drawVerticalLine": {
|
|
16
|
-
"typeof": "function"
|
|
17
|
-
},
|
|
18
|
-
"drawHorizontalLine": {
|
|
19
|
-
"typeof": "function"
|
|
20
|
-
},
|
|
21
|
-
"singleLine": {
|
|
22
|
-
"typeof": "boolean"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"additionalProperties": false
|
|
26
|
-
}
|
package/dist/schemas/shared.json
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "shared.json",
|
|
3
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"definitions": {
|
|
5
|
-
"columns": {
|
|
6
|
-
"type": "object",
|
|
7
|
-
"patternProperties": {
|
|
8
|
-
"^[0-9]+$": {
|
|
9
|
-
"$ref": "#/definitions/column"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"additionalProperties": false
|
|
13
|
-
},
|
|
14
|
-
"column": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"properties": {
|
|
17
|
-
"alignment": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"enum": [
|
|
20
|
-
"left",
|
|
21
|
-
"right",
|
|
22
|
-
"center"
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
"width": {
|
|
26
|
-
"type": "number"
|
|
27
|
-
},
|
|
28
|
-
"wrapWord": {
|
|
29
|
-
"type": "boolean"
|
|
30
|
-
},
|
|
31
|
-
"truncate": {
|
|
32
|
-
"type": "number"
|
|
33
|
-
},
|
|
34
|
-
"paddingLeft": {
|
|
35
|
-
"type": "number"
|
|
36
|
-
},
|
|
37
|
-
"paddingRight": {
|
|
38
|
-
"type": "number"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"additionalProperties": false
|
|
42
|
-
},
|
|
43
|
-
"borders": {
|
|
44
|
-
"type": "object",
|
|
45
|
-
"properties": {
|
|
46
|
-
"topBody": {
|
|
47
|
-
"$ref": "#/definitions/border"
|
|
48
|
-
},
|
|
49
|
-
"topJoin": {
|
|
50
|
-
"$ref": "#/definitions/border"
|
|
51
|
-
},
|
|
52
|
-
"topLeft": {
|
|
53
|
-
"$ref": "#/definitions/border"
|
|
54
|
-
},
|
|
55
|
-
"topRight": {
|
|
56
|
-
"$ref": "#/definitions/border"
|
|
57
|
-
},
|
|
58
|
-
"bottomBody": {
|
|
59
|
-
"$ref": "#/definitions/border"
|
|
60
|
-
},
|
|
61
|
-
"bottomJoin": {
|
|
62
|
-
"$ref": "#/definitions/border"
|
|
63
|
-
},
|
|
64
|
-
"bottomLeft": {
|
|
65
|
-
"$ref": "#/definitions/border"
|
|
66
|
-
},
|
|
67
|
-
"bottomRight": {
|
|
68
|
-
"$ref": "#/definitions/border"
|
|
69
|
-
},
|
|
70
|
-
"bodyLeft": {
|
|
71
|
-
"$ref": "#/definitions/border"
|
|
72
|
-
},
|
|
73
|
-
"bodyRight": {
|
|
74
|
-
"$ref": "#/definitions/border"
|
|
75
|
-
},
|
|
76
|
-
"bodyJoin": {
|
|
77
|
-
"$ref": "#/definitions/border"
|
|
78
|
-
},
|
|
79
|
-
"joinBody": {
|
|
80
|
-
"$ref": "#/definitions/border"
|
|
81
|
-
},
|
|
82
|
-
"joinLeft": {
|
|
83
|
-
"$ref": "#/definitions/border"
|
|
84
|
-
},
|
|
85
|
-
"joinRight": {
|
|
86
|
-
"$ref": "#/definitions/border"
|
|
87
|
-
},
|
|
88
|
-
"joinJoin": {
|
|
89
|
-
"$ref": "#/definitions/border"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"additionalProperties": false
|
|
93
|
-
},
|
|
94
|
-
"border": {
|
|
95
|
-
"type": "string"
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "streamConfig.json",
|
|
3
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"border": {
|
|
7
|
-
"$ref": "shared.json#/definitions/borders"
|
|
8
|
-
},
|
|
9
|
-
"columns": {
|
|
10
|
-
"$ref": "shared.json#/definitions/columns"
|
|
11
|
-
},
|
|
12
|
-
"columnDefault": {
|
|
13
|
-
"$ref": "shared.json#/definitions/column"
|
|
14
|
-
},
|
|
15
|
-
"columnCount": {
|
|
16
|
-
"type": "number"
|
|
17
|
-
},
|
|
18
|
-
"drawVerticalLine": {
|
|
19
|
-
"typeof": "function"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"additionalProperties": false
|
|
23
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Casts all cell values to a string.
|
|
10
|
-
*
|
|
11
|
-
* @param {table~row[]} rows
|
|
12
|
-
* @returns {table~row[]}
|
|
13
|
-
*/
|
|
14
|
-
const stringifyTableData = rows => {
|
|
15
|
-
return rows.map(cells => {
|
|
16
|
-
return cells.map(String);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var _default = stringifyTableData;
|
|
21
|
-
exports.default = _default;
|