table 6.1.0 → 6.3.2
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/alignString.d.ts +6 -0
- package/dist/alignString.js +51 -95
- package/dist/alignTableData.d.ts +3 -0
- package/dist/alignTableData.js +17 -31
- package/dist/calculateCellHeight.d.ts +2 -0
- package/dist/calculateCellHeight.js +14 -35
- package/dist/calculateCellWidthIndex.d.ts +6 -0
- package/dist/calculateCellWidthIndex.js +11 -22
- package/dist/calculateMaximumColumnWidthIndex.d.ts +6 -0
- package/dist/calculateMaximumColumnWidthIndex.js +18 -30
- package/dist/calculateRowHeightIndex.d.ts +6 -0
- package/dist/calculateRowHeightIndex.js +23 -39
- package/dist/createStream.d.ts +3 -0
- package/dist/createStream.js +65 -116
- package/dist/drawBorder.d.ts +25 -0
- package/dist/drawBorder.js +45 -106
- package/dist/drawHorizontalContent.d.ts +11 -0
- package/dist/drawHorizontalContent.js +17 -40
- package/dist/drawRow.d.ts +7 -0
- package/dist/drawRow.js +14 -39
- package/dist/drawTable.d.ts +3 -0
- package/dist/drawTable.js +33 -56
- package/dist/generated/validators.d.ts +13 -0
- package/dist/{validators.js → generated/validators.js} +309 -315
- package/dist/getBorderCharacters.d.ts +3 -0
- package/dist/getBorderCharacters.js +79 -115
- package/dist/{index.js.flow → index.d.ts} +2 -6
- package/dist/index.js +22 -30
- package/dist/makeConfig.d.ts +8 -0
- package/dist/makeConfig.js +42 -84
- package/dist/makeStreamConfig.d.ts +8 -0
- package/dist/makeStreamConfig.js +42 -90
- package/dist/mapDataUsingRowHeightIndex.d.ts +3 -0
- package/dist/mapDataUsingRowHeightIndex.js +23 -38
- package/dist/padTableData.d.ts +3 -0
- package/dist/padTableData.js +7 -20
- package/dist/stringifyTableData.d.ts +3 -0
- package/dist/stringifyTableData.js +5 -19
- package/dist/table.d.ts +3 -0
- package/dist/table.js +25 -119
- package/dist/truncateTableData.d.ts +6 -0
- package/dist/truncateTableData.js +13 -23
- package/dist/types/api.d.ts +100 -0
- package/dist/types/api.js +2 -0
- package/dist/types/internal.d.ts +1 -0
- package/dist/types/internal.js +2 -0
- package/dist/validateConfig.d.ts +3 -0
- package/dist/validateConfig.js +22 -38
- package/dist/validateTableData.d.ts +2 -0
- package/dist/validateTableData.js +23 -49
- package/dist/wrapCell.d.ts +9 -0
- package/dist/wrapCell.js +23 -38
- package/dist/wrapString.d.ts +10 -0
- package/dist/wrapString.js +14 -29
- package/dist/wrapWord.d.ts +2 -0
- package/dist/wrapWord.js +26 -44
- package/package.json +32 -24
- package/dist/alignString.js.flow +0 -97
- package/dist/alignTableData.js.flow +0 -21
- package/dist/calculateCellHeight.js.flow +0 -24
- package/dist/calculateCellWidthIndex.js.flow +0 -17
- package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
- package/dist/calculateRowHeightIndex.js.flow +0 -36
- package/dist/createStream.js.flow +0 -125
- package/dist/drawBorder.js.flow +0 -89
- package/dist/drawHorizontalContent.js.flow +0 -31
- package/dist/drawRow.js.flow +0 -29
- package/dist/drawTable.js.flow +0 -64
- package/dist/getBorderCharacters.js.flow +0 -120
- package/dist/makeConfig.js.flow +0 -85
- package/dist/makeStreamConfig.js.flow +0 -92
- package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
- 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.flow +0 -11
- package/dist/table.js.flow +0 -108
- package/dist/truncateTableData.js.flow +0 -17
- package/dist/validateConfig.js.flow +0 -27
- package/dist/validateTableData.js.flow +0 -44
- package/dist/wrapCell.js.flow +0 -35
- package/dist/wrapString.js.flow +0 -29
- package/dist/wrapWord.js.flow +0 -39
|
@@ -1,118 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
2
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
joinLeft: '|',
|
|
89
|
-
joinRight: '|',
|
|
90
|
-
joinJoin: '|'
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (name === 'void') {
|
|
95
|
-
return {
|
|
96
|
-
topBody: '',
|
|
97
|
-
topJoin: '',
|
|
98
|
-
topLeft: '',
|
|
99
|
-
topRight: '',
|
|
100
|
-
bottomBody: '',
|
|
101
|
-
bottomJoin: '',
|
|
102
|
-
bottomLeft: '',
|
|
103
|
-
bottomRight: '',
|
|
104
|
-
bodyLeft: '',
|
|
105
|
-
bodyRight: '',
|
|
106
|
-
bodyJoin: '',
|
|
107
|
-
joinBody: '',
|
|
108
|
-
joinLeft: '',
|
|
109
|
-
joinRight: '',
|
|
110
|
-
joinJoin: ''
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
throw new Error('Unknown border template "' + name + '".');
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = (name) => {
|
|
5
|
+
if (name === 'honeywell') {
|
|
6
|
+
return {
|
|
7
|
+
topBody: '═',
|
|
8
|
+
topJoin: '╤',
|
|
9
|
+
topLeft: '╔',
|
|
10
|
+
topRight: '╗',
|
|
11
|
+
bottomBody: '═',
|
|
12
|
+
bottomJoin: '╧',
|
|
13
|
+
bottomLeft: '╚',
|
|
14
|
+
bottomRight: '╝',
|
|
15
|
+
bodyLeft: '║',
|
|
16
|
+
bodyRight: '║',
|
|
17
|
+
bodyJoin: '│',
|
|
18
|
+
joinBody: '─',
|
|
19
|
+
joinLeft: '╟',
|
|
20
|
+
joinRight: '╢',
|
|
21
|
+
joinJoin: '┼',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (name === 'norc') {
|
|
25
|
+
return {
|
|
26
|
+
topBody: '─',
|
|
27
|
+
topJoin: '┬',
|
|
28
|
+
topLeft: '┌',
|
|
29
|
+
topRight: '┐',
|
|
30
|
+
bottomBody: '─',
|
|
31
|
+
bottomJoin: '┴',
|
|
32
|
+
bottomLeft: '└',
|
|
33
|
+
bottomRight: '┘',
|
|
34
|
+
bodyLeft: '│',
|
|
35
|
+
bodyRight: '│',
|
|
36
|
+
bodyJoin: '│',
|
|
37
|
+
joinBody: '─',
|
|
38
|
+
joinLeft: '├',
|
|
39
|
+
joinRight: '┤',
|
|
40
|
+
joinJoin: '┼',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (name === 'ramac') {
|
|
44
|
+
return {
|
|
45
|
+
topBody: '-',
|
|
46
|
+
topJoin: '+',
|
|
47
|
+
topLeft: '+',
|
|
48
|
+
topRight: '+',
|
|
49
|
+
bottomBody: '-',
|
|
50
|
+
bottomJoin: '+',
|
|
51
|
+
bottomLeft: '+',
|
|
52
|
+
bottomRight: '+',
|
|
53
|
+
bodyLeft: '|',
|
|
54
|
+
bodyRight: '|',
|
|
55
|
+
bodyJoin: '|',
|
|
56
|
+
joinBody: '-',
|
|
57
|
+
joinLeft: '|',
|
|
58
|
+
joinRight: '|',
|
|
59
|
+
joinJoin: '|',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (name === 'void') {
|
|
63
|
+
return {
|
|
64
|
+
topBody: '',
|
|
65
|
+
topJoin: '',
|
|
66
|
+
topLeft: '',
|
|
67
|
+
topRight: '',
|
|
68
|
+
bottomBody: '',
|
|
69
|
+
bottomJoin: '',
|
|
70
|
+
bottomLeft: '',
|
|
71
|
+
bottomRight: '',
|
|
72
|
+
bodyLeft: '',
|
|
73
|
+
bodyRight: '',
|
|
74
|
+
bodyJoin: '',
|
|
75
|
+
joinBody: '',
|
|
76
|
+
joinLeft: '',
|
|
77
|
+
joinRight: '',
|
|
78
|
+
joinJoin: '',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Unknown border template "' + name + '".');
|
|
115
82
|
};
|
|
116
|
-
|
|
117
|
-
var _default = getBorderCharacters;
|
|
118
|
-
exports.default = _default;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import createStream from './createStream';
|
|
2
2
|
import getBorderCharacters from './getBorderCharacters';
|
|
3
3
|
import table from './table';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
table,
|
|
7
|
-
createStream,
|
|
8
|
-
getBorderCharacters,
|
|
9
|
-
};
|
|
4
|
+
export { table, createStream, getBorderCharacters, };
|
|
5
|
+
export * from './types/api';
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var _createStream = _interopRequireDefault(require("./createStream"));
|
|
26
|
-
|
|
27
|
-
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
|
|
28
|
-
|
|
29
|
-
var _table = _interopRequireDefault(require("./table"));
|
|
30
|
-
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getBorderCharacters = exports.createStream = exports.table = void 0;
|
|
17
|
+
const createStream_1 = __importDefault(require("./createStream"));
|
|
18
|
+
exports.createStream = createStream_1.default;
|
|
19
|
+
const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
|
|
20
|
+
exports.getBorderCharacters = getBorderCharacters_1.default;
|
|
21
|
+
const table_1 = __importDefault(require("./table"));
|
|
22
|
+
exports.table = table_1.default;
|
|
23
|
+
__exportStar(require("./types/api"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TableUserConfig } from './types/api';
|
|
2
|
+
import type { Row, TableConfig } from './types/internal';
|
|
3
|
+
declare const _default: (rows: Row[], userConfig?: TableUserConfig) => TableConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Makes a new configuration object out of the userConfig object
|
|
6
|
+
* using default values for the missing configuration properties.
|
|
7
|
+
*/
|
|
8
|
+
export default _default;
|
package/dist/makeConfig.js
CHANGED
|
@@ -1,100 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
7
|
+
const calculateMaximumColumnWidthIndex_1 = __importDefault(require("./calculateMaximumColumnWidthIndex"));
|
|
8
|
+
const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
|
|
9
|
+
const validateConfig_1 = __importDefault(require("./validateConfig"));
|
|
18
10
|
/**
|
|
19
11
|
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
20
|
-
*
|
|
21
|
-
* @param {object} border
|
|
22
|
-
* @returns {object}
|
|
23
12
|
*/
|
|
24
|
-
const makeBorder = (border
|
|
25
|
-
|
|
13
|
+
const makeBorder = (border) => {
|
|
14
|
+
return {
|
|
15
|
+
...getBorderCharacters_1.default('honeywell'),
|
|
16
|
+
...border,
|
|
17
|
+
};
|
|
26
18
|
};
|
|
27
19
|
/**
|
|
28
20
|
* Creates a configuration for every column using default
|
|
29
21
|
* values for the missing configuration properties.
|
|
30
|
-
*
|
|
31
|
-
* @param {Array[]} rows
|
|
32
|
-
* @param {object} columns
|
|
33
|
-
* @param {object} columnDefault
|
|
34
|
-
* @returns {object}
|
|
35
22
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
51
|
-
width: maximumColumnWidthIndex[index],
|
|
52
|
-
wrapWord: false
|
|
53
|
-
}, columnDefault, columns[index]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return columns;
|
|
23
|
+
const makeColumns = (rows, columns, columnDefault) => {
|
|
24
|
+
const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex_1.default(rows);
|
|
25
|
+
return rows[0].map((_cell, index) => {
|
|
26
|
+
return {
|
|
27
|
+
alignment: 'left',
|
|
28
|
+
paddingLeft: 1,
|
|
29
|
+
paddingRight: 1,
|
|
30
|
+
truncate: Number.POSITIVE_INFINITY,
|
|
31
|
+
width: maximumColumnWidthIndex[index],
|
|
32
|
+
wrapWord: false,
|
|
33
|
+
...columnDefault,
|
|
34
|
+
...columns === null || columns === void 0 ? void 0 : columns[index],
|
|
35
|
+
};
|
|
36
|
+
});
|
|
57
37
|
};
|
|
58
38
|
/**
|
|
59
39
|
* Makes a new configuration object out of the userConfig object
|
|
60
40
|
* using default values for the missing configuration properties.
|
|
61
|
-
*
|
|
62
|
-
* @param {Array[]} rows
|
|
63
|
-
* @param {object} userConfig
|
|
64
|
-
* @returns {object}
|
|
65
41
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!config.drawVerticalLine) {
|
|
84
|
-
/**
|
|
85
|
-
* @returns {boolean}
|
|
86
|
-
*/
|
|
87
|
-
config.drawVerticalLine = () => {
|
|
88
|
-
return true;
|
|
42
|
+
exports.default = (rows, userConfig = {}) => {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
validateConfig_1.default('config.json', userConfig);
|
|
45
|
+
const config = lodash_clonedeep_1.default(userConfig);
|
|
46
|
+
return {
|
|
47
|
+
...config,
|
|
48
|
+
border: makeBorder(config.border),
|
|
49
|
+
columns: makeColumns(rows, config.columns, config.columnDefault),
|
|
50
|
+
drawHorizontalLine: (_a = config.drawHorizontalLine) !== null && _a !== void 0 ? _a : (() => {
|
|
51
|
+
return true;
|
|
52
|
+
}),
|
|
53
|
+
drawVerticalLine: (_b = config.drawVerticalLine) !== null && _b !== void 0 ? _b : (() => {
|
|
54
|
+
return true;
|
|
55
|
+
}),
|
|
56
|
+
singleLine: (_c = config.singleLine) !== null && _c !== void 0 ? _c : false,
|
|
89
57
|
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (config.singleLine === undefined) {
|
|
93
|
-
config.singleLine = false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return config;
|
|
97
58
|
};
|
|
98
|
-
|
|
99
|
-
var _default = makeConfig;
|
|
100
|
-
exports.default = _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StreamUserConfig } from './types/api';
|
|
2
|
+
import type { StreamConfig } from './types/internal';
|
|
3
|
+
declare const _default: (userConfig: StreamUserConfig) => StreamConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Makes a new configuration object out of the userConfig object
|
|
6
|
+
* using default values for the missing configuration properties.
|
|
7
|
+
*/
|
|
8
|
+
export default _default;
|
package/dist/makeStreamConfig.js
CHANGED
|
@@ -1,107 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
7
|
+
const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
|
|
8
|
+
const validateConfig_1 = __importDefault(require("./validateConfig"));
|
|
16
9
|
/**
|
|
17
10
|
* Merges user provided border characters with the default border ("honeywell") characters.
|
|
18
11
|
*
|
|
19
|
-
* @param {object} border
|
|
20
|
-
* @returns {object}
|
|
21
12
|
*/
|
|
22
|
-
const makeBorder = (border
|
|
23
|
-
|
|
13
|
+
const makeBorder = (border) => {
|
|
14
|
+
return {
|
|
15
|
+
...getBorderCharacters_1.default('honeywell'),
|
|
16
|
+
...border,
|
|
17
|
+
};
|
|
24
18
|
};
|
|
25
19
|
/**
|
|
26
20
|
* Creates a configuration for every column using default
|
|
27
21
|
* values for the missing configuration properties.
|
|
28
|
-
*
|
|
29
|
-
* @param {number} columnCount
|
|
30
|
-
* @param {object} columns
|
|
31
|
-
* @param {object} columnDefault
|
|
32
|
-
* @returns {object}
|
|
33
22
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
truncate: Number.POSITIVE_INFINITY,
|
|
47
|
-
wrapWord: false
|
|
48
|
-
}, columnDefault, columns[index]);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return columns;
|
|
23
|
+
const makeColumns = (columnCount, columns = {}, columnDefault) => {
|
|
24
|
+
return Array.from({ length: columnCount }).map((_, index) => {
|
|
25
|
+
return {
|
|
26
|
+
alignment: 'left',
|
|
27
|
+
paddingLeft: 1,
|
|
28
|
+
paddingRight: 1,
|
|
29
|
+
truncate: Number.POSITIVE_INFINITY,
|
|
30
|
+
wrapWord: false,
|
|
31
|
+
...columnDefault,
|
|
32
|
+
...columns[index],
|
|
33
|
+
};
|
|
34
|
+
});
|
|
52
35
|
};
|
|
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
36
|
/**
|
|
71
37
|
* Makes a new configuration object out of the userConfig object
|
|
72
38
|
* using default values for the missing configuration properties.
|
|
73
|
-
*
|
|
74
|
-
* @param {streamConfig} userConfig
|
|
75
|
-
* @returns {object}
|
|
76
39
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @returns {boolean}
|
|
97
|
-
*/
|
|
98
|
-
config.drawVerticalLine = () => {
|
|
99
|
-
return true;
|
|
40
|
+
exports.default = (userConfig) => {
|
|
41
|
+
var _a;
|
|
42
|
+
validateConfig_1.default('streamConfig.json', userConfig);
|
|
43
|
+
const config = lodash_clonedeep_1.default(userConfig);
|
|
44
|
+
if (!config.columnDefault || !config.columnDefault.width) {
|
|
45
|
+
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
|
46
|
+
}
|
|
47
|
+
if (!config.columnCount) {
|
|
48
|
+
throw new Error('Must provide config.columnCount.');
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...config,
|
|
52
|
+
border: makeBorder(config.border),
|
|
53
|
+
columnCount: config.columnCount,
|
|
54
|
+
columns: makeColumns(config.columnCount, config.columns, config.columnDefault),
|
|
55
|
+
drawVerticalLine: (_a = config.drawVerticalLine) !== null && _a !== void 0 ? _a : (() => {
|
|
56
|
+
return true;
|
|
57
|
+
}),
|
|
100
58
|
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return config;
|
|
104
59
|
};
|
|
105
|
-
|
|
106
|
-
var _default = makeStreamConfig;
|
|
107
|
-
exports.default = _default;
|
|
@@ -1,41 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
|
|
7
|
+
const wrapCell_1 = __importDefault(require("./wrapCell"));
|
|
8
|
+
exports.default = (unmappedRows, rowHeightIndex, config) => {
|
|
9
|
+
const tableWidth = unmappedRows[0].length;
|
|
10
|
+
const mappedRows = unmappedRows.map((row, index0) => {
|
|
11
|
+
const rowHeight = Array.from({ length: rowHeightIndex[index0] }, () => {
|
|
12
|
+
return new Array(tableWidth).fill('');
|
|
13
|
+
});
|
|
14
|
+
// rowHeight
|
|
15
|
+
// [{row index within rowSaw; index2}]
|
|
16
|
+
// [{cell index within a virtual row; index1}]
|
|
17
|
+
row.forEach((cell, index1) => {
|
|
18
|
+
const cellLines = wrapCell_1.default(cell, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
19
|
+
cellLines.forEach((cellLine, index2) => {
|
|
20
|
+
rowHeight[index2][index1] = cellLine;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return rowHeight;
|
|
34
24
|
});
|
|
35
|
-
return
|
|
36
|
-
});
|
|
37
|
-
return (0, _lodash.default)(mappedRows);
|
|
25
|
+
return lodash_flatten_1.default(mappedRows);
|
|
38
26
|
};
|
|
39
|
-
|
|
40
|
-
var _default = mapDataUsingRowHeightIndex;
|
|
41
|
-
exports.default = _default;
|