table 6.7.0 → 6.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{alignString.d.ts → src/alignString.d.ts} +0 -0
- package/dist/{alignString.js → src/alignString.js} +4 -3
- package/dist/{alignTableData.d.ts → src/alignTableData.d.ts} +0 -0
- package/dist/{alignTableData.js → src/alignTableData.js} +2 -1
- package/dist/{calculateCellHeight.d.ts → src/calculateCellHeight.d.ts} +0 -0
- package/dist/{calculateCellHeight.js → src/calculateCellHeight.js} +2 -1
- package/dist/{calculateCellWidths.d.ts → src/calculateCellWidths.d.ts} +0 -0
- package/dist/{calculateCellWidths.js → src/calculateCellWidths.js} +1 -0
- package/dist/{calculateColumnWidths.d.ts → src/calculateColumnWidths.d.ts} +0 -0
- package/dist/{calculateColumnWidths.js → src/calculateColumnWidths.js} +2 -1
- package/dist/{calculateRowHeights.d.ts → src/calculateRowHeights.d.ts} +0 -0
- package/dist/{calculateRowHeights.js → src/calculateRowHeights.js} +2 -1
- package/dist/{createStream.d.ts → src/createStream.d.ts} +0 -0
- package/dist/{createStream.js → src/createStream.js} +14 -13
- package/dist/{drawBorder.d.ts → src/drawBorder.d.ts} +3 -3
- package/dist/{drawBorder.js → src/drawBorder.js} +2 -1
- package/dist/{drawContent.d.ts → src/drawContent.d.ts} +0 -0
- package/dist/{drawContent.js → src/drawContent.js} +1 -0
- package/dist/{drawHeader.d.ts → src/drawHeader.d.ts} +0 -0
- package/dist/{drawHeader.js → src/drawHeader.js} +7 -6
- package/dist/{drawRow.d.ts → src/drawRow.d.ts} +0 -0
- package/dist/{drawRow.js → src/drawRow.js} +2 -1
- package/dist/{drawTable.d.ts → src/drawTable.d.ts} +0 -0
- package/dist/{drawTable.js → src/drawTable.js} +7 -6
- package/dist/{generated → src/generated}/validators.d.ts +0 -0
- package/dist/{generated → src/generated}/validators.js +5 -4
- package/dist/{getBorderCharacters.d.ts → src/getBorderCharacters.d.ts} +0 -0
- package/dist/{getBorderCharacters.js → src/getBorderCharacters.js} +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +0 -0
- package/dist/{index.js → src/index.js} +1 -1
- package/dist/{makeStreamConfig.d.ts → src/makeStreamConfig.d.ts} +1 -1
- package/dist/{makeStreamConfig.js → src/makeStreamConfig.js} +4 -8
- package/dist/{makeTableConfig.d.ts → src/makeTableConfig.d.ts} +1 -1
- package/dist/{makeTableConfig.js → src/makeTableConfig.js} +5 -6
- package/dist/{mapDataUsingRowHeights.d.ts → src/mapDataUsingRowHeights.d.ts} +0 -0
- package/dist/{mapDataUsingRowHeights.js → src/mapDataUsingRowHeights.js} +2 -1
- package/dist/{padTableData.d.ts → src/padTableData.d.ts} +0 -0
- package/dist/{padTableData.js → src/padTableData.js} +2 -1
- package/dist/{stringifyTableData.d.ts → src/stringifyTableData.d.ts} +0 -0
- package/dist/{stringifyTableData.js → src/stringifyTableData.js} +2 -1
- package/dist/{table.d.ts → src/table.d.ts} +0 -0
- package/dist/src/table.js +27 -0
- package/dist/{truncateTableData.d.ts → src/truncateTableData.d.ts} +0 -0
- package/dist/{truncateTableData.js → src/truncateTableData.js} +3 -2
- package/dist/{types → src/types}/api.d.ts +0 -0
- package/dist/{types → src/types}/api.js +1 -0
- package/dist/{types → src/types}/internal.d.ts +0 -0
- package/dist/{types → src/types}/internal.js +1 -0
- package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
- package/dist/{utils.js → src/utils.js} +5 -5
- package/dist/{validateConfig.d.ts → src/validateConfig.d.ts} +0 -0
- package/dist/{validateConfig.js → src/validateConfig.js} +2 -0
- package/dist/{validateTableData.d.ts → src/validateTableData.d.ts} +0 -0
- package/dist/{validateTableData.js → src/validateTableData.js} +2 -1
- package/dist/{wrapCell.d.ts → src/wrapCell.d.ts} +0 -0
- package/dist/{wrapCell.js → src/wrapCell.js} +4 -3
- package/dist/{wrapString.d.ts → src/wrapString.d.ts} +0 -0
- package/dist/{wrapString.js → src/wrapString.js} +4 -3
- package/dist/{wrapWord.d.ts → src/wrapWord.d.ts} +0 -0
- package/dist/{wrapWord.js → src/wrapWord.js} +5 -4
- package/dist/test/README/api/getBorderCharacters.d.ts +1 -0
- package/dist/test/README/api/getBorderCharacters.js +76 -0
- package/dist/test/README/api/stream/streaming.d.ts +1 -0
- package/dist/test/README/api/stream/streaming.js +41 -0
- package/dist/test/README/api/table/border.d.ts +1 -0
- package/dist/test/README/api/table/border.js +45 -0
- package/dist/test/README/api/table/column/alignment.d.ts +1 -0
- package/dist/test/README/api/table/column/alignment.js +34 -0
- package/dist/test/README/api/table/column/padding.d.ts +1 -0
- package/dist/test/README/api/table/column/padding.js +36 -0
- package/dist/test/README/api/table/column/truncate.d.ts +1 -0
- package/dist/test/README/api/table/column/truncate.js +29 -0
- package/dist/test/README/api/table/column/verticalAlignment.d.ts +1 -0
- package/dist/test/README/api/table/column/verticalAlignment.js +28 -0
- package/dist/test/README/api/table/column/width.d.ts +1 -0
- package/dist/test/README/api/table/column/width.js +30 -0
- package/dist/test/README/api/table/column/wrapWord.d.ts +1 -0
- package/dist/test/README/api/table/column/wrapWord.js +51 -0
- package/dist/test/README/api/table/drawHorizontalLine.d.ts +1 -0
- package/dist/test/README/api/table/drawHorizontalLine.js +33 -0
- package/dist/test/README/api/table/drawVerticalLine.d.ts +1 -0
- package/dist/test/README/api/table/drawVerticalLine.js +35 -0
- package/dist/test/README/api/table/header.d.ts +1 -0
- package/dist/test/README/api/table/header.js +35 -0
- package/dist/test/README/api/table/singleLine.d.ts +1 -0
- package/dist/test/README/api/table/singleLine.js +35 -0
- package/dist/test/README/demo.d.ts +1 -0
- package/dist/test/README/demo.js +71 -0
- package/dist/test/README/usage.d.ts +1 -0
- package/dist/test/README/usage.js +24 -0
- package/dist/test/alignString.d.ts +1 -0
- package/dist/test/alignString.js +124 -0
- package/dist/test/alignTableData.d.ts +1 -0
- package/dist/test/alignTableData.js +63 -0
- package/dist/test/calculateCellHeight.d.ts +1 -0
- package/dist/test/calculateCellHeight.js +28 -0
- package/dist/test/calculateCellWidths.d.ts +1 -0
- package/dist/test/calculateCellWidths.js +27 -0
- package/dist/test/calculateColumnWidths.d.ts +1 -0
- package/dist/test/calculateColumnWidths.js +54 -0
- package/dist/test/calculateRowHeights.d.ts +1 -0
- package/dist/test/calculateRowHeights.js +61 -0
- package/dist/test/createStream.d.ts +1 -0
- package/dist/test/createStream.js +122 -0
- package/dist/test/drawBorder.d.ts +1 -0
- package/dist/test/drawBorder.js +139 -0
- package/dist/test/drawHeader.d.ts +1 -0
- package/dist/test/drawHeader.js +172 -0
- package/dist/test/drawRow.d.ts +1 -0
- package/dist/test/drawRow.js +54 -0
- package/dist/test/getBorderCharacters.d.ts +1 -0
- package/dist/test/getBorderCharacters.js +104 -0
- package/dist/test/makeConfig.d.ts +1 -0
- package/dist/test/makeConfig.js +152 -0
- package/dist/test/makeStreamConfig.d.ts +1 -0
- package/dist/test/makeStreamConfig.js +106 -0
- package/dist/test/mapDataUsingRowHeights.d.ts +1 -0
- package/dist/test/mapDataUsingRowHeights.js +150 -0
- package/dist/test/padTableData.d.ts +1 -0
- package/dist/test/padTableData.js +62 -0
- package/dist/test/streamConfigSamples.d.ts +6 -0
- package/dist/test/streamConfigSamples.js +287 -0
- package/dist/test/stringifyTableData.d.ts +1 -0
- package/dist/test/stringifyTableData.js +17 -0
- package/dist/test/table.d.ts +1 -0
- package/dist/test/table.js +171 -0
- package/dist/test/tableConfigSamples.d.ts +5 -0
- package/dist/test/tableConfigSamples.js +202 -0
- package/dist/test/truncateTableData.d.ts +1 -0
- package/dist/test/truncateTableData.js +92 -0
- package/dist/test/utils.d.ts +7 -0
- package/dist/test/utils.js +23 -0
- package/dist/test/validateConfig.d.ts +1 -0
- package/dist/test/validateConfig.js +36 -0
- package/dist/test/validateStreamConfig.d.ts +1 -0
- package/dist/test/validateStreamConfig.js +39 -0
- package/dist/test/validateTableConfig.d.ts +1 -0
- package/dist/test/validateTableConfig.js +35 -0
- package/dist/test/validateTableData.d.ts +1 -0
- package/dist/test/validateTableData.js +106 -0
- package/dist/test/wrapCell.d.ts +1 -0
- package/dist/test/wrapCell.js +114 -0
- package/dist/test/wrapString.d.ts +1 -0
- package/dist/test/wrapString.js +45 -0
- package/dist/test/wrapWord.d.ts +1 -0
- package/dist/test/wrapWord.js +94 -0
- package/package.json +14 -30
- package/dist/table.js +0 -26
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-nested-callbacks */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const src_1 = require("../src");
|
|
6
|
+
const validateTableData_1 = require("../src/validateTableData");
|
|
7
|
+
describe('validateTableData', () => {
|
|
8
|
+
context('table does not have a row', () => {
|
|
9
|
+
it('throws an error', () => {
|
|
10
|
+
(0, chai_1.expect)(() => {
|
|
11
|
+
(0, validateTableData_1.validateTableData)([]);
|
|
12
|
+
}).to.throw(Error, 'Table must define at least one row.');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
context('table does not have a column', () => {
|
|
16
|
+
it('throws an error', () => {
|
|
17
|
+
(0, chai_1.expect)(() => {
|
|
18
|
+
(0, validateTableData_1.validateTableData)([[]]);
|
|
19
|
+
}).to.throw(Error, 'Table must define at least one column.');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
context('row data is not an array', () => {
|
|
23
|
+
it('throws an error', () => {
|
|
24
|
+
(0, chai_1.expect)(() => {
|
|
25
|
+
(0, validateTableData_1.validateTableData)({});
|
|
26
|
+
}).to.throw(Error, 'Table data must be an array.');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
context('column data is not an array', () => {
|
|
30
|
+
it('throws an error', () => {
|
|
31
|
+
(0, chai_1.expect)(() => {
|
|
32
|
+
(0, validateTableData_1.validateTableData)([{}]);
|
|
33
|
+
}).to.throw(Error, 'Table row data must be an array.');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
context('cell data contains a control character', () => {
|
|
37
|
+
it('throws an error', () => {
|
|
38
|
+
(0, chai_1.expect)(() => {
|
|
39
|
+
(0, validateTableData_1.validateTableData)([
|
|
40
|
+
[
|
|
41
|
+
String.fromCodePoint(0x01),
|
|
42
|
+
],
|
|
43
|
+
]);
|
|
44
|
+
}).to.throw(Error, 'Table data must not contain control characters.');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
context('cell data contains newlines', () => {
|
|
48
|
+
it('does not throw', () => {
|
|
49
|
+
(0, chai_1.expect)(() => {
|
|
50
|
+
(0, validateTableData_1.validateTableData)([['ab\nc']]);
|
|
51
|
+
}).to.not.throw();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
context('cell data contains Windows-style newlines', () => {
|
|
55
|
+
it('does not throw and replaces by Unix-style newline', () => {
|
|
56
|
+
(0, chai_1.expect)(() => {
|
|
57
|
+
(0, validateTableData_1.validateTableData)([['ab\r\nc']]);
|
|
58
|
+
}).to.not.throw();
|
|
59
|
+
(0, chai_1.expect)((0, src_1.table)([['ab\r\nc']])).to.equal('╔════╗\n║ ab ║\n║ c ║\n╚════╝\n');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
context('cell data contains carriage return only', () => {
|
|
63
|
+
it('throws an error', () => {
|
|
64
|
+
(0, chai_1.expect)(() => {
|
|
65
|
+
(0, validateTableData_1.validateTableData)([['ab\rc']]);
|
|
66
|
+
}).to.throw(Error, 'Table data must not contain control characters.');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
context('cell data contains hyperlinks', () => {
|
|
70
|
+
const OSC = '\u001B]';
|
|
71
|
+
const BEL = '\u0007';
|
|
72
|
+
const SEP = ';';
|
|
73
|
+
const url = 'https://example.com';
|
|
74
|
+
const text = 'This is a link to example.com';
|
|
75
|
+
const link = [
|
|
76
|
+
OSC,
|
|
77
|
+
'8',
|
|
78
|
+
SEP,
|
|
79
|
+
SEP,
|
|
80
|
+
url,
|
|
81
|
+
BEL,
|
|
82
|
+
text,
|
|
83
|
+
OSC,
|
|
84
|
+
'8',
|
|
85
|
+
SEP,
|
|
86
|
+
SEP,
|
|
87
|
+
BEL,
|
|
88
|
+
].join('');
|
|
89
|
+
it('does not throw', () => {
|
|
90
|
+
(0, chai_1.expect)(() => {
|
|
91
|
+
(0, validateTableData_1.validateTableData)([[link]]);
|
|
92
|
+
}).to.not.throw();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
context('rows have inconsistent number of cells', () => {
|
|
96
|
+
it('throws an error', () => {
|
|
97
|
+
(0, chai_1.expect)(() => {
|
|
98
|
+
(0, validateTableData_1.validateTableData)([
|
|
99
|
+
['a', 'b', 'c'],
|
|
100
|
+
['a', 'b'],
|
|
101
|
+
]);
|
|
102
|
+
}).to.throw(Error, 'Table must have a consistent number of cells.');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=validateTableData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-nested-callbacks */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const wrapCell_1 = require("../src/wrapCell");
|
|
6
|
+
const wrapString_1 = require("../src/wrapString");
|
|
7
|
+
const wrapWord_1 = require("../src/wrapWord");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
describe('wrapCell', () => {
|
|
10
|
+
const strings = ['aa bb cc', 'a a bb cccc', 'aaabbcc', 'a\\bb', 'a_bb', 'a-bb', 'a.bb', 'a,bb', 'a;bb'];
|
|
11
|
+
context('useWrapWord is enabled', () => {
|
|
12
|
+
context('the string does not contain the newline character', () => {
|
|
13
|
+
it('returns the same output as wrapWord\'s', () => {
|
|
14
|
+
for (const string of strings) {
|
|
15
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(string, 3, true)).to.deep.equal((0, wrapWord_1.wrapWord)(string, 3));
|
|
16
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)(string), 3, true)).to.deep.equal((0, utils_1.arrayToRed)((0, wrapWord_1.wrapWord)(string, 3)));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
context('the string does contains the newline character', () => {
|
|
21
|
+
context('the length of lineChunk is smaller than the length of container', () => {
|
|
22
|
+
it('splits by the newlines', () => {
|
|
23
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n', 5, true)).to.deep.equal(['', '']);
|
|
24
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\n', 5, true)).to.deep.equal(['a', '']);
|
|
25
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\na', 5, true)).to.deep.equal(['', 'a']);
|
|
26
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\na\n', 5, true)).to.deep.equal(['', 'a', '']);
|
|
27
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\na', 5, true)).to.deep.equal(['a', 'a']);
|
|
28
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a \na', 5, true)).to.deep.equal(['a', 'a']);
|
|
29
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n\n', 5, true)).to.deep.equal(['', '', '']);
|
|
30
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\n\n', 5, true)).to.deep.equal(['a', '', '']);
|
|
31
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n\na', 5, true)).to.deep.equal(['', '', 'a']);
|
|
32
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\n\nb', 5, true)).to.deep.equal(['a', '', 'b']);
|
|
33
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\n\n\nb', 5, true)).to.deep.equal(['a', '', '', 'b']);
|
|
34
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('\n'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['', '']));
|
|
35
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\n'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', '']));
|
|
36
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('\na'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['', 'a']));
|
|
37
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('\na\n'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['', 'a', '']));
|
|
38
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\na'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', 'a']));
|
|
39
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a \na'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', 'a']));
|
|
40
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('\n\n'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['', '', '']));
|
|
41
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\n\n'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', '', '']));
|
|
42
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('\n\na'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['', '', 'a']));
|
|
43
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\n\nb'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', '', 'b']));
|
|
44
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\n\n\nb'), 5, true)).to.deep.equal((0, utils_1.arrayToRed)(['a', '', '', 'b']));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
context('the length of lineChunk is longer than the length of container', () => {
|
|
48
|
+
it('continues cut the word by wrapWord function', () => {
|
|
49
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaa bbb\nc', 3, true)).to.deep.equal(['aaa', 'bbb', 'c']);
|
|
50
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a b c\nd', 3, true)).to.deep.equal(['a b', 'c', 'd']);
|
|
51
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaaa\nbbbb', 3, true)).to.deep.equal(['aaa', 'a', 'bbb', 'b']);
|
|
52
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a\\bb\nc', 3, true)).to.deep.equal(['a\\', 'bb', 'c']);
|
|
53
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a/bb\nc', 3, true)).to.deep.equal(['a/', 'bb', 'c']);
|
|
54
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a_bb\nc', 3, true)).to.deep.equal(['a_', 'bb', 'c']);
|
|
55
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a-bb\nc', 3, true)).to.deep.equal(['a-', 'bb', 'c']);
|
|
56
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a.bb\nc', 3, true)).to.deep.equal(['a.', 'bb', 'c']);
|
|
57
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a,bb\nc', 3, true)).to.deep.equal(['a,', 'bb', 'c']);
|
|
58
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a;bb\nc', 3, true)).to.deep.equal(['a;', 'bb', 'c']);
|
|
59
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaa-b\nc', 3, true)).to.deep.equal(['aaa', '-b', 'c']);
|
|
60
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('aaa bbb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['aaa', 'bbb', 'c']));
|
|
61
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a b c\nd'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a b', 'c', 'd']));
|
|
62
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('aaaa\nbbbb'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['aaa', 'a', 'bbb', 'b']));
|
|
63
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a\\bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a\\', 'bb', 'c']));
|
|
64
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a/bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a/', 'bb', 'c']));
|
|
65
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a_bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a_', 'bb', 'c']));
|
|
66
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a-bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a-', 'bb', 'c']));
|
|
67
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a.bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a.', 'bb', 'c']));
|
|
68
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a,bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a,', 'bb', 'c']));
|
|
69
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('a;bb\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['a;', 'bb', 'c']));
|
|
70
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)((0, utils_1.stringToRed)('aaa-b\nc'), 3, true)).to.deep.equal((0, utils_1.arrayToRed)(['aaa', '-b', 'c']));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
context('useWrapWord is disable', () => {
|
|
76
|
+
context('the string does not contain the newline character', () => {
|
|
77
|
+
it('returns the same output as wrapString\'s', () => {
|
|
78
|
+
for (const string of strings) {
|
|
79
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(string, 3, false)).to.deep.equal((0, wrapString_1.wrapString)(string, 3));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
context('the string contains the newline character', () => {
|
|
84
|
+
context('the length of lineChunk is smaller than the length of container', () => {
|
|
85
|
+
it('splits by the newlines and does not trim the chunks', () => {
|
|
86
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n', 5, false)).to.deep.equal(['', '']);
|
|
87
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' a \n', 5, false)).to.deep.equal([' a ', '']);
|
|
88
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n a ', 5, false)).to.deep.equal(['', ' a ']);
|
|
89
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n a \n', 5, false)).to.deep.equal(['', ' a ', '']);
|
|
90
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' a \n b ', 5, false)).to.deep.equal([' a ', ' b ']);
|
|
91
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n\n', 5, false)).to.deep.equal(['', '', '']);
|
|
92
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' a \n\n', 5, false)).to.deep.equal([' a ', '', '']);
|
|
93
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('\n\n a ', 5, false)).to.deep.equal(['', '', ' a ']);
|
|
94
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' a \n\n b ', 5, false)).to.deep.equal([' a ', '', ' b ']);
|
|
95
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' a \n\n\n b ', 5, false)).to.deep.equal([' a ', '', '', ' b ']);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
context('the length of lineChunk is longer than the length of container', () => {
|
|
99
|
+
it('cuts each chunkLine by wrapString and trim the small chunk if it starts with whitespace', () => {
|
|
100
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)(' \nb', 3, false)).to.deep.equal([' ', 'b']);
|
|
101
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a \nb', 3, false)).to.deep.equal(['a ', 'b']);
|
|
102
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aa \nb', 3, false)).to.deep.equal(['aa ', 'b']);
|
|
103
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaa \nb', 3, false)).to.deep.equal(['aaa', 'b']);
|
|
104
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaaa\nb', 3, false)).to.deep.equal(['aaa', 'a', 'b']);
|
|
105
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a b\nc', 3, false)).to.deep.equal(['a ', 'b', 'c']);
|
|
106
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a b\nc', 3, false)).to.deep.equal(['a ', 'b', 'c']);
|
|
107
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('a b\nc', 3, false)).to.deep.equal(['a ', 'b', 'c']);
|
|
108
|
+
(0, chai_1.expect)((0, wrapCell_1.wrapCell)('aaa b\n c', 3, false)).to.deep.equal(['aaa', 'b', ' c']);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=wrapCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-nested-callbacks */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const wrapString_1 = require("../src/wrapString");
|
|
6
|
+
describe('wrapString', () => {
|
|
7
|
+
context('subject is a plain text string', () => {
|
|
8
|
+
context('subject is lesser than the chunk size', () => {
|
|
9
|
+
it('returns subject in a single chunk', () => {
|
|
10
|
+
(0, chai_1.expect)((0, wrapString_1.wrapString)('aaa', 3)).to.deep.equal(['aaa']);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
context('subject is larger than the chunk size', () => {
|
|
14
|
+
it('returns subject sliced into multiple chunks', () => {
|
|
15
|
+
(0, chai_1.expect)((0, wrapString_1.wrapString)('aaabbbc', 3)).to.deep.equal(['aaa', 'bbb', 'c']);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
context('a chunk starts with a space', () => {
|
|
19
|
+
it('adjusts chunks to offset the space', () => {
|
|
20
|
+
(0, chai_1.expect)((0, wrapString_1.wrapString)('aaa bbb ccc', 3)).to.deep.equal(['aaa', 'bbb', 'ccc']);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
context('subject string contains ANSI escape codes', () => {
|
|
25
|
+
const openRed = '\u001b[31m';
|
|
26
|
+
const closeRed = '\u001b[39m';
|
|
27
|
+
describe('subject is lesser than the chunk size', () => {
|
|
28
|
+
it('returns subject in a single chunk', () => {
|
|
29
|
+
(0, chai_1.expect)((0, wrapString_1.wrapString)(`${openRed}aa${closeRed}`, 3)).to.deep.equal([
|
|
30
|
+
`${openRed}aa${closeRed}`,
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('subject is larger than the chunk size', () => {
|
|
35
|
+
it('returns subject sliced into multiple chunks', () => {
|
|
36
|
+
(0, chai_1.expect)((0, wrapString_1.wrapString)(`${openRed}aaabbbc${closeRed}`, 3)).to.deep.equal([
|
|
37
|
+
`${openRed}aaa${closeRed}`,
|
|
38
|
+
`${openRed}bbb${closeRed}`,
|
|
39
|
+
`${openRed}c${closeRed}`,
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=wrapString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const wrapWord_1 = require("../src/wrapWord");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
describe('wrapWord', () => {
|
|
7
|
+
it('wraps a string at a nearest whitespace', () => {
|
|
8
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa bbb', 5)).to.deep.equal(['aaa', 'bbb']);
|
|
9
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('a a a bbb', 5)).to.deep.equal(['a a a', 'bbb']);
|
|
10
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa', 'bbb']));
|
|
11
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('a a a bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['a a a', 'bbb']));
|
|
12
|
+
});
|
|
13
|
+
context('a single word is longer than chunk size', () => {
|
|
14
|
+
it('cuts the word', () => {
|
|
15
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaaaa', 2)).to.deep.equal(['aa', 'aa', 'a']);
|
|
16
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaaaa'), 2)).to.deep.equal((0, utils_1.arrayToRed)(['aa', 'aa', 'a']));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
context('empty string', () => {
|
|
20
|
+
it('should return empty string as well', () => {
|
|
21
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('', 0)).to.deep.equal(['']);
|
|
22
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('', 1)).to.deep.equal(['']);
|
|
23
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('', 2)).to.deep.equal(['']);
|
|
24
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('', 3)).to.deep.equal(['']);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
context('a long word with a special character', () => {
|
|
28
|
+
it('cuts the word at the special character', () => {
|
|
29
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa\\bbb', 5)).to.deep.equal(['aaa\\', 'bbb']);
|
|
30
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa/bbb', 5)).to.deep.equal(['aaa/', 'bbb']);
|
|
31
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa_bbb', 5)).to.deep.equal(['aaa_', 'bbb']);
|
|
32
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa-bbb', 5)).to.deep.equal(['aaa-', 'bbb']);
|
|
33
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa.bbb', 5)).to.deep.equal(['aaa.', 'bbb']);
|
|
34
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa,bbb', 5)).to.deep.equal(['aaa,', 'bbb']);
|
|
35
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aaa;bbb', 5)).to.deep.equal(['aaa;', 'bbb']);
|
|
36
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa\\bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa\\', 'bbb']));
|
|
37
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa/bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa/', 'bbb']));
|
|
38
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa_bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa_', 'bbb']));
|
|
39
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa-bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa-', 'bbb']));
|
|
40
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa.bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa.', 'bbb']));
|
|
41
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa,bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa,', 'bbb']));
|
|
42
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aaa;bbb'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aaa;', 'bbb']));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
context('a special character after the length of a container', () => {
|
|
46
|
+
it('does not include special character', () => {
|
|
47
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)('aa-bbbbb-cccc', 5)).to.deep.equal(['aa-', 'bbbbb', '-cccc']);
|
|
48
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)((0, utils_1.stringToRed)('aa-bbbbb-cccc'), 5)).to.deep.equal((0, utils_1.arrayToRed)(['aa-', 'bbbbb', '-cccc']));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
context('mixed ansi and plain', () => {
|
|
52
|
+
it('returns proper strings', () => {
|
|
53
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)(`${utils_1.openRed}Lorem ${utils_1.closeRed}ipsum dolor ${utils_1.openRed}sit amet${utils_1.closeRed}`, 5)).to.deep.equal([
|
|
54
|
+
`${utils_1.openRed}Lorem${utils_1.closeRed}`,
|
|
55
|
+
'ipsum',
|
|
56
|
+
'dolor',
|
|
57
|
+
`${utils_1.openRed}sit${utils_1.closeRed}`,
|
|
58
|
+
`${utils_1.openRed}amet${utils_1.closeRed}`,
|
|
59
|
+
]);
|
|
60
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)(`${utils_1.openRed}Lorem ${utils_1.closeRed}ipsum dolor ${utils_1.openRed}sit amet${utils_1.closeRed}`, 11)).to.deep.equal([
|
|
61
|
+
`${utils_1.openRed}Lorem ${utils_1.closeRed}ipsum`,
|
|
62
|
+
`dolor ${utils_1.openRed}sit${utils_1.closeRed}`,
|
|
63
|
+
`${utils_1.openRed}amet${utils_1.closeRed}`,
|
|
64
|
+
]);
|
|
65
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)(`${utils_1.openRed}Lorem ip${utils_1.closeRed}sum dolor si${utils_1.openRed}t amet${utils_1.closeRed}`, 5)).to.deep.equal([
|
|
66
|
+
`${utils_1.openRed}Lorem${utils_1.closeRed}`,
|
|
67
|
+
`${utils_1.openRed}ip${utils_1.closeRed}sum`,
|
|
68
|
+
'dolor',
|
|
69
|
+
`si${utils_1.openRed}t${utils_1.closeRed}`,
|
|
70
|
+
`${utils_1.openRed}amet${utils_1.closeRed}`,
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
context('multiple ansi', () => {
|
|
75
|
+
it('returns proper strings', () => {
|
|
76
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)(`${utils_1.openBold}${utils_1.openRed}Lorem ipsum dolor sit${utils_1.closeRed}${utils_1.closeBold}`, 4)).to.deep.equal([
|
|
77
|
+
`${utils_1.openBold}${utils_1.openRed}Lore${utils_1.closeRed}${utils_1.closeBold}`,
|
|
78
|
+
`${utils_1.openBold}${utils_1.openRed}m${utils_1.closeRed}${utils_1.closeBold}`,
|
|
79
|
+
`${utils_1.openBold}${utils_1.openRed}ipsu${utils_1.closeRed}${utils_1.closeBold}`,
|
|
80
|
+
`${utils_1.openBold}${utils_1.openRed}m${utils_1.closeRed}${utils_1.closeBold}`,
|
|
81
|
+
`${utils_1.openBold}${utils_1.openRed}dolo${utils_1.closeRed}${utils_1.closeBold}`,
|
|
82
|
+
`${utils_1.openBold}${utils_1.openRed}r${utils_1.closeRed}${utils_1.closeBold}`,
|
|
83
|
+
`${utils_1.openBold}${utils_1.openRed}sit${utils_1.closeBold}${utils_1.closeRed}`
|
|
84
|
+
]);
|
|
85
|
+
(0, chai_1.expect)((0, wrapWord_1.wrapWord)(`${utils_1.openBold}${utils_1.openRed}Lorem ipsum dolor sit${utils_1.closeRed}${utils_1.closeBold}`, 5)).to.deep.equal([
|
|
86
|
+
`${utils_1.openBold}${utils_1.openRed}Lorem${utils_1.closeRed}${utils_1.closeBold}`,
|
|
87
|
+
`${utils_1.openBold}${utils_1.openRed}ipsum${utils_1.closeRed}${utils_1.closeBold}`,
|
|
88
|
+
`${utils_1.openBold}${utils_1.openRed}dolor${utils_1.closeRed}${utils_1.closeBold}`,
|
|
89
|
+
`${utils_1.openBold}${utils_1.openRed}sit${utils_1.closeBold}${utils_1.closeRed}`
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=wrapWord.js.map
|
package/package.json
CHANGED
|
@@ -6,19 +6,17 @@
|
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"ajv": "^8.0.1",
|
|
9
|
-
"lodash.clonedeep": "^4.5.0",
|
|
10
9
|
"lodash.truncate": "^4.4.2",
|
|
11
10
|
"slice-ansi": "^4.0.0",
|
|
12
|
-
"string-width": "^4.2.
|
|
13
|
-
"strip-ansi": "^6.0.
|
|
11
|
+
"string-width": "^4.2.3",
|
|
12
|
+
"strip-ansi": "^6.0.1"
|
|
14
13
|
},
|
|
15
14
|
"description": "Formats data into a string table.",
|
|
16
15
|
"devDependencies": {
|
|
17
16
|
"@types/chai": "^4.2.16",
|
|
18
|
-
"@types/lodash.clonedeep": "^4.5.6",
|
|
19
17
|
"@types/lodash.mapvalues": "^4.6.6",
|
|
20
18
|
"@types/lodash.truncate": "^4.4.6",
|
|
21
|
-
"@types/mocha": "^
|
|
19
|
+
"@types/mocha": "^9.0.0",
|
|
22
20
|
"@types/node": "^14.14.37",
|
|
23
21
|
"@types/sinon": "^10.0.0",
|
|
24
22
|
"@types/slice-ansi": "^4.0.0",
|
|
@@ -27,19 +25,19 @@
|
|
|
27
25
|
"chai": "^4.2.0",
|
|
28
26
|
"chalk": "^4.1.0",
|
|
29
27
|
"coveralls": "^3.1.0",
|
|
30
|
-
"eslint": "^7.
|
|
28
|
+
"eslint": "^7.32.0",
|
|
31
29
|
"eslint-config-canonical": "^25.0.0",
|
|
32
|
-
"gitdown": "^3.1.
|
|
30
|
+
"gitdown": "^3.1.4",
|
|
33
31
|
"husky": "^4.3.6",
|
|
34
|
-
"js-beautify": "^1.
|
|
32
|
+
"js-beautify": "^1.14.0",
|
|
35
33
|
"lodash.mapvalues": "^4.6.0",
|
|
36
34
|
"mkdirp": "^1.0.4",
|
|
37
35
|
"mocha": "^8.2.1",
|
|
38
36
|
"nyc": "^15.1.0",
|
|
39
37
|
"semantic-release": "^17.3.1",
|
|
40
|
-
"sinon": "^
|
|
38
|
+
"sinon": "^12.0.1",
|
|
41
39
|
"ts-node": "^9.1.1",
|
|
42
|
-
"typescript": "4.2
|
|
40
|
+
"typescript": "4.5.2"
|
|
43
41
|
},
|
|
44
42
|
"engines": {
|
|
45
43
|
"node": ">=10.0.0"
|
|
@@ -64,31 +62,17 @@
|
|
|
64
62
|
"dist/**/*.d.ts"
|
|
65
63
|
],
|
|
66
64
|
"name": "table",
|
|
67
|
-
"nyc": {
|
|
68
|
-
"extensions": [
|
|
69
|
-
".ts"
|
|
70
|
-
],
|
|
71
|
-
"exclude": [
|
|
72
|
-
"src/generated/validators.js",
|
|
73
|
-
"test/**/*.ts"
|
|
74
|
-
],
|
|
75
|
-
"reporter": [
|
|
76
|
-
"text-lcov",
|
|
77
|
-
"text"
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
65
|
"repository": {
|
|
81
66
|
"type": "git",
|
|
82
67
|
"url": "https://github.com/gajus/table"
|
|
83
68
|
},
|
|
84
69
|
"scripts": {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"build": "npm run create-validators && npm run compile",
|
|
70
|
+
"prebuild": "rm -fr ./src/generated && mkdirp ./src/generated",
|
|
71
|
+
"build": "npm run create-validators && tsc",
|
|
88
72
|
"create-readme": "gitdown ./.README/README.md --output-file ./README.md",
|
|
89
|
-
"create-validators": "
|
|
90
|
-
"lint": "eslint
|
|
91
|
-
"test": "
|
|
73
|
+
"create-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -s src/schemas/streamConfig -r src/schemas/shared -c ajv-keywords/dist/keywords/typeof -o | js-beautify > ./src/generated/validators.js",
|
|
74
|
+
"lint": "eslint ./src ./test",
|
|
75
|
+
"test": "nyc mocha && nyc check-coverage --lines 95"
|
|
92
76
|
},
|
|
93
|
-
"version": "6.7.
|
|
77
|
+
"version": "6.7.4"
|
|
94
78
|
}
|
package/dist/table.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.table = void 0;
|
|
4
|
-
const alignTableData_1 = require("./alignTableData");
|
|
5
|
-
const calculateCellWidths_1 = require("./calculateCellWidths");
|
|
6
|
-
const calculateRowHeights_1 = require("./calculateRowHeights");
|
|
7
|
-
const drawTable_1 = require("./drawTable");
|
|
8
|
-
const makeTableConfig_1 = require("./makeTableConfig");
|
|
9
|
-
const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights");
|
|
10
|
-
const padTableData_1 = require("./padTableData");
|
|
11
|
-
const stringifyTableData_1 = require("./stringifyTableData");
|
|
12
|
-
const truncateTableData_1 = require("./truncateTableData");
|
|
13
|
-
const validateTableData_1 = require("./validateTableData");
|
|
14
|
-
const table = (data, userConfig = {}) => {
|
|
15
|
-
validateTableData_1.validateTableData(data);
|
|
16
|
-
let rows = stringifyTableData_1.stringifyTableData(data);
|
|
17
|
-
const config = makeTableConfig_1.makeTableConfig(rows, userConfig);
|
|
18
|
-
rows = truncateTableData_1.truncateTableData(rows, config);
|
|
19
|
-
const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config);
|
|
20
|
-
rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config);
|
|
21
|
-
rows = alignTableData_1.alignTableData(rows, config);
|
|
22
|
-
rows = padTableData_1.padTableData(rows, config);
|
|
23
|
-
const cellWidths = calculateCellWidths_1.calculateCellWidths(rows[0]);
|
|
24
|
-
return drawTable_1.drawTable(rows, cellWidths, rowHeights, config);
|
|
25
|
-
};
|
|
26
|
-
exports.table = table;
|