table 4.0.1 → 4.0.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/dist/alignString.js +3 -3
- package/dist/alignTableData.js +2 -6
- package/dist/calculateCellHeight.js +2 -2
- package/dist/calculateCellWidthIndex.js +1 -5
- package/dist/calculateRowHeightIndex.js +2 -2
- package/dist/createStream.js +1 -1
- package/dist/drawTable.js +3 -1
- package/dist/makeConfig.js +3 -3
- package/dist/makeStreamConfig.js +2 -2
- package/dist/mapDataUsingRowHeightIndex.js +1 -1
- package/dist/schemas/config.json +2 -2
- package/dist/schemas/streamConfig.json +2 -2
- package/dist/stringifyTableData.js +3 -9
- package/dist/validateConfig.js +20 -23
- package/dist/validateStreamConfig.js +17 -19
- package/dist/validateTableData.js +9 -15
- package/package.json +22 -22
- package/test/README/usage/basic.js +0 -27
- package/test/README/usage/cell_content_alignment.js +0 -47
- package/test/README/usage/column_width.js +0 -35
- package/test/README/usage/custom_border.js +0 -52
- package/test/README/usage/draw_horizontal_line.js +0 -43
- package/test/README/usage/expectTable.js +0 -13
- package/test/README/usage/moon_mission.js +0 -68
- package/test/README/usage/padding_cell_content.js +0 -41
- package/test/README/usage/predefined_border_templates.js +0 -92
- package/test/README/usage/streaming.js +0 -56
- package/test/README/usage/text_truncating.js +0 -34
- package/test/README/usage/text_wrapping.js +0 -69
- package/test/alignString.js +0 -102
- package/test/calculateCellHeight.js +0 -44
- package/test/calculateCellWidthIndex.js +0 -20
- package/test/calculateMaximumColumnWidthIndex.js +0 -59
- package/test/calculateRowHeightIndex.js +0 -78
- package/test/config.js +0 -43
- package/test/configSamples.js +0 -153
- package/test/createStream.js +0 -41
- package/test/drawBorder.js +0 -71
- package/test/makeConfig.js +0 -75
- package/test/mapDataUsingRowHeightIndex.js +0 -119
- package/test/streamConfig.js +0 -43
- package/test/streamConfigSamples.js +0 -151
- package/test/validateTableData.js +0 -65
- package/test/wrapString.js +0 -45
- package/test/wrapWord.js +0 -32
package/dist/alignString.js
CHANGED
|
@@ -65,11 +65,11 @@ const alignCenter = (subject, width) => {
|
|
|
65
65
|
|
|
66
66
|
exports.default = (subject, containerWidth, alignment) => {
|
|
67
67
|
if (!_lodash2.default.isString(subject)) {
|
|
68
|
-
throw new
|
|
68
|
+
throw new TypeError('Subject parameter value must be a string.');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (!_lodash2.default.isNumber(containerWidth)) {
|
|
72
|
-
throw new
|
|
72
|
+
throw new TypeError('Container width parameter value must be a number.');
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const subjectWidth = (0, _stringWidth2.default)(subject);
|
|
@@ -81,7 +81,7 @@ exports.default = (subject, containerWidth, alignment) => {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (!_lodash2.default.isString(alignment)) {
|
|
84
|
-
throw new
|
|
84
|
+
throw new TypeError('Alignment parameter value must be a string.');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
if (alignments.indexOf(alignment) === -1) {
|
package/dist/alignTableData.js
CHANGED
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _lodash = require('lodash');
|
|
8
|
-
|
|
9
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
10
|
-
|
|
11
7
|
var _stringWidth = require('string-width');
|
|
12
8
|
|
|
13
9
|
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
|
@@ -24,8 +20,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
20
|
* @returns {table~row[]}
|
|
25
21
|
*/
|
|
26
22
|
exports.default = (rows, config) => {
|
|
27
|
-
return
|
|
28
|
-
return
|
|
23
|
+
return rows.map(cells => {
|
|
24
|
+
return cells.map((value, index1) => {
|
|
29
25
|
const column = config.columns[index1];
|
|
30
26
|
|
|
31
27
|
if ((0, _stringWidth2.default)(value) === column.width) {
|
|
@@ -28,11 +28,11 @@ exports.default = function (value, columnWidth) {
|
|
|
28
28
|
let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
29
29
|
|
|
30
30
|
if (!_lodash2.default.isString(value)) {
|
|
31
|
-
throw new
|
|
31
|
+
throw new TypeError('Value must be a string.');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (!_lodash2.default.isInteger(columnWidth)) {
|
|
35
|
-
throw new
|
|
35
|
+
throw new TypeError('Column width must be an integer.');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
if (columnWidth < 1) {
|
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _lodash = require('lodash');
|
|
8
|
-
|
|
9
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
10
|
-
|
|
11
7
|
var _stringWidth = require('string-width');
|
|
12
8
|
|
|
13
9
|
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
|
@@ -21,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
17
|
* @returns {number[]}
|
|
22
18
|
*/
|
|
23
19
|
exports.default = cells => {
|
|
24
|
-
return
|
|
20
|
+
return cells.map(value => {
|
|
25
21
|
return (0, _stringWidth2.default)(value);
|
|
26
22
|
});
|
|
27
23
|
};
|
|
@@ -31,11 +31,11 @@ exports.default = (rows, config) => {
|
|
|
31
31
|
|
|
32
32
|
_lodash2.default.forEach(cells, (value, index1) => {
|
|
33
33
|
if (!_lodash2.default.isNumber(config.columns[index1].width)) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new TypeError('column[index].width must be a number.');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) {
|
|
38
|
-
throw new
|
|
38
|
+
throw new TypeError('column[index].wrapWord must be a boolean.');
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
package/dist/createStream.js
CHANGED
package/dist/drawTable.js
CHANGED
|
@@ -25,7 +25,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
* @returns {string}
|
|
26
26
|
*/
|
|
27
27
|
exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
|
|
28
|
-
let output
|
|
28
|
+
let output;
|
|
29
|
+
let realRowIndex;
|
|
30
|
+
let rowHeight;
|
|
29
31
|
|
|
30
32
|
const rowCount = rows.length;
|
|
31
33
|
|
package/dist/makeConfig.js
CHANGED
|
@@ -31,7 +31,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
31
|
const makeBorder = function makeBorder() {
|
|
32
32
|
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
33
33
|
|
|
34
|
-
return
|
|
34
|
+
return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -88,8 +88,8 @@ exports.default = function (rows) {
|
|
|
88
88
|
|
|
89
89
|
if (!config.drawHorizontalLine) {
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
* @returns {boolean}
|
|
92
|
+
*/
|
|
93
93
|
config.drawHorizontalLine = () => {
|
|
94
94
|
return true;
|
|
95
95
|
};
|
package/dist/makeStreamConfig.js
CHANGED
|
@@ -27,7 +27,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
const makeBorder = function makeBorder() {
|
|
28
28
|
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -48,7 +48,7 @@ const makeColumns = function makeColumns(columnCount) {
|
|
|
48
48
|
columns[index] = {};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
columns[index] =
|
|
51
|
+
columns[index] = Object.assign({
|
|
52
52
|
alignment: 'left',
|
|
53
53
|
paddingLeft: 1,
|
|
54
54
|
paddingRight: 1,
|
|
@@ -27,7 +27,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
exports.default = (unmappedRows, rowHeightIndex, config) => {
|
|
28
28
|
const tableWidth = unmappedRows[0].length;
|
|
29
29
|
|
|
30
|
-
const mappedRows =
|
|
30
|
+
const mappedRows = unmappedRows.map((cells, index0) => {
|
|
31
31
|
const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => {
|
|
32
32
|
return _lodash2.default.fill(Array(tableWidth), '');
|
|
33
33
|
});
|
package/dist/schemas/config.json
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _lodash = require('lodash');
|
|
8
|
-
|
|
9
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
7
|
/**
|
|
14
8
|
* Casts all cell values to a string.
|
|
15
9
|
*
|
|
@@ -17,7 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
11
|
* @returns {table~row[]}
|
|
18
12
|
*/
|
|
19
13
|
exports.default = rows => {
|
|
20
|
-
return
|
|
21
|
-
return
|
|
14
|
+
return rows.map(cells => {
|
|
15
|
+
return cells.map(String);
|
|
22
16
|
});
|
|
23
17
|
};
|
package/dist/validateConfig.js
CHANGED
|
@@ -243,7 +243,6 @@ var validate = (function() {
|
|
|
243
243
|
'use strict';
|
|
244
244
|
var vErrors = null;
|
|
245
245
|
var errors = 0;
|
|
246
|
-
if (rootData === undefined) rootData = data;
|
|
247
246
|
if (typeof data !== "string") {
|
|
248
247
|
var err = {
|
|
249
248
|
keyword: 'type',
|
|
@@ -341,7 +340,6 @@ var validate = (function() {
|
|
|
341
340
|
'use strict';
|
|
342
341
|
var vErrors = null;
|
|
343
342
|
var errors = 0;
|
|
344
|
-
if (rootData === undefined) rootData = data;
|
|
345
343
|
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
|
346
344
|
var errs__0 = errors;
|
|
347
345
|
var valid1 = true;
|
|
@@ -366,6 +364,20 @@ var validate = (function() {
|
|
|
366
364
|
var data1 = data.alignment;
|
|
367
365
|
if (data1 !== undefined) {
|
|
368
366
|
var errs_1 = errors;
|
|
367
|
+
if (typeof data1 !== "string") {
|
|
368
|
+
var err = {
|
|
369
|
+
keyword: 'type',
|
|
370
|
+
dataPath: (dataPath || '') + '.alignment',
|
|
371
|
+
schemaPath: '#/properties/alignment/type',
|
|
372
|
+
params: {
|
|
373
|
+
type: 'string'
|
|
374
|
+
},
|
|
375
|
+
message: 'should be string'
|
|
376
|
+
};
|
|
377
|
+
if (vErrors === null) vErrors = [err];
|
|
378
|
+
else vErrors.push(err);
|
|
379
|
+
errors++;
|
|
380
|
+
}
|
|
369
381
|
var schema1 = validate.schema.properties.alignment.enum;
|
|
370
382
|
var valid1;
|
|
371
383
|
valid1 = false;
|
|
@@ -388,20 +400,6 @@ var validate = (function() {
|
|
|
388
400
|
else vErrors.push(err);
|
|
389
401
|
errors++;
|
|
390
402
|
}
|
|
391
|
-
if (typeof data1 !== "string") {
|
|
392
|
-
var err = {
|
|
393
|
-
keyword: 'type',
|
|
394
|
-
dataPath: (dataPath || '') + '.alignment',
|
|
395
|
-
schemaPath: '#/properties/alignment/type',
|
|
396
|
-
params: {
|
|
397
|
-
type: 'string'
|
|
398
|
-
},
|
|
399
|
-
message: 'should be string'
|
|
400
|
-
};
|
|
401
|
-
if (vErrors === null) vErrors = [err];
|
|
402
|
-
else vErrors.push(err);
|
|
403
|
-
errors++;
|
|
404
|
-
}
|
|
405
403
|
var valid1 = errors === errs_1;
|
|
406
404
|
}
|
|
407
405
|
if (data.width !== undefined) {
|
|
@@ -540,7 +538,7 @@ var validate = (function() {
|
|
|
540
538
|
refVal4.errors = null;
|
|
541
539
|
refVal[4] = refVal4;
|
|
542
540
|
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
|
543
|
-
'use strict';
|
|
541
|
+
'use strict'; /*# sourceURL=config.json */
|
|
544
542
|
var vErrors = null;
|
|
545
543
|
var errors = 0;
|
|
546
544
|
if (rootData === undefined) rootData = data;
|
|
@@ -596,7 +594,8 @@ var validate = (function() {
|
|
|
596
594
|
var errs_1 = errors;
|
|
597
595
|
var errs__1 = errors;
|
|
598
596
|
var valid1;
|
|
599
|
-
|
|
597
|
+
valid1 = typeof data.drawHorizontalLine == "function";
|
|
598
|
+
if (!valid1) {
|
|
600
599
|
if (errs__1 == errors) {
|
|
601
600
|
var err = {
|
|
602
601
|
keyword: 'typeof',
|
|
@@ -613,9 +612,7 @@ var validate = (function() {
|
|
|
613
612
|
} else {
|
|
614
613
|
for (var i1 = errs__1; i1 < errors; i1++) {
|
|
615
614
|
var ruleErr1 = vErrors[i1];
|
|
616
|
-
if (ruleErr1.dataPath === undefined)
|
|
617
|
-
ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
|
|
618
|
-
}
|
|
615
|
+
if (ruleErr1.dataPath === undefined) ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
|
|
619
616
|
if (ruleErr1.schemaPath === undefined) {
|
|
620
617
|
ruleErr1.schemaPath = "#/properties/drawHorizontalLine/typeof";
|
|
621
618
|
}
|
|
@@ -643,8 +640,8 @@ var validate = (function() {
|
|
|
643
640
|
};
|
|
644
641
|
})();
|
|
645
642
|
validate.schema = {
|
|
646
|
-
"id": "config.json",
|
|
647
|
-
"$schema": "http://json-schema.org/draft-
|
|
643
|
+
"$id": "config.json",
|
|
644
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
648
645
|
"type": "object",
|
|
649
646
|
"properties": {
|
|
650
647
|
"border": {
|
|
@@ -243,7 +243,6 @@ var validate = (function() {
|
|
|
243
243
|
'use strict';
|
|
244
244
|
var vErrors = null;
|
|
245
245
|
var errors = 0;
|
|
246
|
-
if (rootData === undefined) rootData = data;
|
|
247
246
|
if (typeof data !== "string") {
|
|
248
247
|
var err = {
|
|
249
248
|
keyword: 'type',
|
|
@@ -341,7 +340,6 @@ var validate = (function() {
|
|
|
341
340
|
'use strict';
|
|
342
341
|
var vErrors = null;
|
|
343
342
|
var errors = 0;
|
|
344
|
-
if (rootData === undefined) rootData = data;
|
|
345
343
|
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
|
346
344
|
var errs__0 = errors;
|
|
347
345
|
var valid1 = true;
|
|
@@ -366,6 +364,20 @@ var validate = (function() {
|
|
|
366
364
|
var data1 = data.alignment;
|
|
367
365
|
if (data1 !== undefined) {
|
|
368
366
|
var errs_1 = errors;
|
|
367
|
+
if (typeof data1 !== "string") {
|
|
368
|
+
var err = {
|
|
369
|
+
keyword: 'type',
|
|
370
|
+
dataPath: (dataPath || '') + '.alignment',
|
|
371
|
+
schemaPath: '#/properties/alignment/type',
|
|
372
|
+
params: {
|
|
373
|
+
type: 'string'
|
|
374
|
+
},
|
|
375
|
+
message: 'should be string'
|
|
376
|
+
};
|
|
377
|
+
if (vErrors === null) vErrors = [err];
|
|
378
|
+
else vErrors.push(err);
|
|
379
|
+
errors++;
|
|
380
|
+
}
|
|
369
381
|
var schema1 = validate.schema.properties.alignment.enum;
|
|
370
382
|
var valid1;
|
|
371
383
|
valid1 = false;
|
|
@@ -388,20 +400,6 @@ var validate = (function() {
|
|
|
388
400
|
else vErrors.push(err);
|
|
389
401
|
errors++;
|
|
390
402
|
}
|
|
391
|
-
if (typeof data1 !== "string") {
|
|
392
|
-
var err = {
|
|
393
|
-
keyword: 'type',
|
|
394
|
-
dataPath: (dataPath || '') + '.alignment',
|
|
395
|
-
schemaPath: '#/properties/alignment/type',
|
|
396
|
-
params: {
|
|
397
|
-
type: 'string'
|
|
398
|
-
},
|
|
399
|
-
message: 'should be string'
|
|
400
|
-
};
|
|
401
|
-
if (vErrors === null) vErrors = [err];
|
|
402
|
-
else vErrors.push(err);
|
|
403
|
-
errors++;
|
|
404
|
-
}
|
|
405
403
|
var valid1 = errors === errs_1;
|
|
406
404
|
}
|
|
407
405
|
if (data.width !== undefined) {
|
|
@@ -540,7 +538,7 @@ var validate = (function() {
|
|
|
540
538
|
refVal4.errors = null;
|
|
541
539
|
refVal[4] = refVal4;
|
|
542
540
|
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
|
543
|
-
'use strict';
|
|
541
|
+
'use strict'; /*# sourceURL=streamConfig.json */
|
|
544
542
|
var vErrors = null;
|
|
545
543
|
var errors = 0;
|
|
546
544
|
if (rootData === undefined) rootData = data;
|
|
@@ -629,8 +627,8 @@ var validate = (function() {
|
|
|
629
627
|
};
|
|
630
628
|
})();
|
|
631
629
|
validate.schema = {
|
|
632
|
-
"id": "streamConfig.json",
|
|
633
|
-
"$schema": "http://json-schema.org/draft-
|
|
630
|
+
"$id": "streamConfig.json",
|
|
631
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
634
632
|
"type": "object",
|
|
635
633
|
"properties": {
|
|
636
634
|
"border": {
|
|
@@ -4,12 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _lodash = require('lodash');
|
|
8
|
-
|
|
9
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
7
|
/**
|
|
14
8
|
* @typedef {string} cell
|
|
15
9
|
*/
|
|
@@ -23,8 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
17
|
* @returns {undefined}
|
|
24
18
|
*/
|
|
25
19
|
exports.default = rows => {
|
|
26
|
-
if (!
|
|
27
|
-
throw new
|
|
20
|
+
if (!Array.isArray(rows)) {
|
|
21
|
+
throw new TypeError('Table data must be an array.');
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
if (rows.length === 0) {
|
|
@@ -37,9 +31,9 @@ exports.default = rows => {
|
|
|
37
31
|
|
|
38
32
|
const columnNumber = rows[0].length;
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
if (!
|
|
42
|
-
throw new
|
|
34
|
+
for (const cells of rows) {
|
|
35
|
+
if (!Array.isArray(cells)) {
|
|
36
|
+
throw new TypeError('Table row data must be an array.');
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
if (cells.length !== columnNumber) {
|
|
@@ -48,10 +42,10 @@ exports.default = rows => {
|
|
|
48
42
|
|
|
49
43
|
// @todo Make an exception for newline characters.
|
|
50
44
|
// @see https://github.com/gajus/table/issues/9
|
|
51
|
-
|
|
52
|
-
if (/[\
|
|
45
|
+
for (const cell of cells) {
|
|
46
|
+
if (/[\u0001-\u001A]/.test(cell)) {
|
|
53
47
|
throw new Error('Table data must not contain control characters.');
|
|
54
48
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
57
51
|
};
|
package/package.json
CHANGED
|
@@ -5,30 +5,30 @@
|
|
|
5
5
|
"url": "http://gajus.com"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"ajv": "^
|
|
9
|
-
"ajv-keywords": "^1.0
|
|
10
|
-
"chalk": "^
|
|
11
|
-
"lodash": "^4.
|
|
12
|
-
"slice-ansi": "0.0
|
|
13
|
-
"string-width": "^2.
|
|
8
|
+
"ajv": "^5.2.3",
|
|
9
|
+
"ajv-keywords": "^2.1.0",
|
|
10
|
+
"chalk": "^2.1.0",
|
|
11
|
+
"lodash": "^4.17.4",
|
|
12
|
+
"slice-ansi": "1.0.0",
|
|
13
|
+
"string-width": "^2.1.1"
|
|
14
14
|
},
|
|
15
15
|
"description": "Formats data into a string table.",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"ajv-cli": "^
|
|
18
|
-
"babel": "^6.
|
|
19
|
-
"babel-cli": "^6.
|
|
20
|
-
"babel-core": "^6.
|
|
21
|
-
"babel-plugin-istanbul": "^
|
|
22
|
-
"babel-preset-es2015-node4": "^2.1.
|
|
23
|
-
"babel-register": "^6.
|
|
24
|
-
"chai": "^
|
|
25
|
-
"eslint": "^
|
|
26
|
-
"eslint-config-canonical": "^
|
|
27
|
-
"gitdown": "^2.
|
|
28
|
-
"husky": "^0.
|
|
29
|
-
"mocha": "^3.
|
|
30
|
-
"nyc": "^
|
|
31
|
-
"sinon": "^
|
|
17
|
+
"ajv-cli": "^2.1.0",
|
|
18
|
+
"babel": "^6.23.0",
|
|
19
|
+
"babel-cli": "^6.26.0",
|
|
20
|
+
"babel-core": "^6.26.0",
|
|
21
|
+
"babel-plugin-istanbul": "^4.1.5",
|
|
22
|
+
"babel-preset-es2015-node4": "^2.1.1",
|
|
23
|
+
"babel-register": "^6.26.0",
|
|
24
|
+
"chai": "^4.1.2",
|
|
25
|
+
"eslint": "^4.7.2",
|
|
26
|
+
"eslint-config-canonical": "^9.3.1",
|
|
27
|
+
"gitdown": "^2.5.1",
|
|
28
|
+
"husky": "^0.14.3",
|
|
29
|
+
"mocha": "^3.5.3",
|
|
30
|
+
"nyc": "^11.2.1",
|
|
31
|
+
"sinon": "^4.0.0"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"ascii",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"prepublish": "NODE_ENV=production npm run build",
|
|
65
65
|
"test": "npm run build && nyc --check-coverage mocha"
|
|
66
66
|
},
|
|
67
|
-
"version": "4.0.
|
|
67
|
+
"version": "4.0.2"
|
|
68
68
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
table
|
|
3
|
-
} from './../../../src';
|
|
4
|
-
import expectTable from './expectTable';
|
|
5
|
-
|
|
6
|
-
describe('README.md usage/', () => {
|
|
7
|
-
it('basic', () => {
|
|
8
|
-
const data = [
|
|
9
|
-
['0A', '0B', '0C'],
|
|
10
|
-
['1A', '1B', '1C'],
|
|
11
|
-
['2A', '2B', '2C']
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
const output = table(data);
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
17
|
-
expectTable(output, `
|
|
18
|
-
╔════╤════╤════╗
|
|
19
|
-
║ 0A │ 0B │ 0C ║
|
|
20
|
-
╟────┼────┼────╢
|
|
21
|
-
║ 1A │ 1B │ 1C ║
|
|
22
|
-
╟────┼────┼────╢
|
|
23
|
-
║ 2A │ 2B │ 2C ║
|
|
24
|
-
╚════╧════╧════╝
|
|
25
|
-
`);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
table
|
|
3
|
-
} from './../../../src';
|
|
4
|
-
import expectTable from './expectTable';
|
|
5
|
-
|
|
6
|
-
describe('README.md usage/', () => {
|
|
7
|
-
it('cell_content_alignment', () => {
|
|
8
|
-
const data = [
|
|
9
|
-
['0A', '0B', '0C'],
|
|
10
|
-
['1A', '1B', '1C'],
|
|
11
|
-
['2A', '2B', '2C']
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
const config = {
|
|
15
|
-
columns: {
|
|
16
|
-
0: {
|
|
17
|
-
alignment: 'left',
|
|
18
|
-
width: 10
|
|
19
|
-
},
|
|
20
|
-
1: {
|
|
21
|
-
alignment: 'center',
|
|
22
|
-
width: 10
|
|
23
|
-
},
|
|
24
|
-
2: {
|
|
25
|
-
alignment: 'right',
|
|
26
|
-
width: 10
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const output = table(data, config);
|
|
32
|
-
|
|
33
|
-
// console.log(output);
|
|
34
|
-
|
|
35
|
-
/* eslint-disable no-restricted-syntax */
|
|
36
|
-
expectTable(output, `
|
|
37
|
-
╔════════════╤════════════╤════════════╗
|
|
38
|
-
║ 0A │ 0B │ 0C ║
|
|
39
|
-
╟────────────┼────────────┼────────────╢
|
|
40
|
-
║ 1A │ 1B │ 1C ║
|
|
41
|
-
╟────────────┼────────────┼────────────╢
|
|
42
|
-
║ 2A │ 2B │ 2C ║
|
|
43
|
-
╚════════════╧════════════╧════════════╝
|
|
44
|
-
`);
|
|
45
|
-
/* eslint-enable no-restricted-syntax */
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
table
|
|
3
|
-
} from './../../../src';
|
|
4
|
-
import expectTable from './expectTable';
|
|
5
|
-
|
|
6
|
-
describe('README.md usage/', () => {
|
|
7
|
-
it('column_width', () => {
|
|
8
|
-
const data = [
|
|
9
|
-
['0A', '0B', '0C'],
|
|
10
|
-
['1A', '1B', '1C'],
|
|
11
|
-
['2A', '2B', '2C']
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
const config = {
|
|
15
|
-
columns: {
|
|
16
|
-
1: {
|
|
17
|
-
width: 10
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const output = table(data, config);
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
25
|
-
expectTable(output, `
|
|
26
|
-
╔════╤════════════╤════╗
|
|
27
|
-
║ 0A │ 0B │ 0C ║
|
|
28
|
-
╟────┼────────────┼────╢
|
|
29
|
-
║ 1A │ 1B │ 1C ║
|
|
30
|
-
╟────┼────────────┼────╢
|
|
31
|
-
║ 2A │ 2B │ 2C ║
|
|
32
|
-
╚════╧════════════╧════╝
|
|
33
|
-
`);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
table
|
|
3
|
-
} from './../../../src';
|
|
4
|
-
import expectTable from './expectTable';
|
|
5
|
-
|
|
6
|
-
describe('README.md usage/', () => {
|
|
7
|
-
it('usage/custom_border', () => {
|
|
8
|
-
const data = [
|
|
9
|
-
['0A', '0B', '0C'],
|
|
10
|
-
['1A', '1B', '1C'],
|
|
11
|
-
['2A', '2B', '2C']
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
/* eslint-disable sort-keys */
|
|
15
|
-
const config = {
|
|
16
|
-
border: {
|
|
17
|
-
topBody: '─',
|
|
18
|
-
topJoin: '┬',
|
|
19
|
-
topLeft: '┌',
|
|
20
|
-
topRight: '┐',
|
|
21
|
-
|
|
22
|
-
bottomBody: '─',
|
|
23
|
-
bottomJoin: '┴',
|
|
24
|
-
bottomLeft: '└',
|
|
25
|
-
bottomRight: '┘',
|
|
26
|
-
|
|
27
|
-
bodyLeft: '│',
|
|
28
|
-
bodyRight: '│',
|
|
29
|
-
bodyJoin: '│',
|
|
30
|
-
|
|
31
|
-
joinBody: '─',
|
|
32
|
-
joinLeft: '├',
|
|
33
|
-
joinRight: '┤',
|
|
34
|
-
joinJoin: '┼'
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/* eslint-enable */
|
|
38
|
-
|
|
39
|
-
const output = table(data, config);
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
42
|
-
expectTable(output, `
|
|
43
|
-
┌────┬────┬────┐
|
|
44
|
-
│ 0A │ 0B │ 0C │
|
|
45
|
-
├────┼────┼────┤
|
|
46
|
-
│ 1A │ 1B │ 1C │
|
|
47
|
-
├────┼────┼────┤
|
|
48
|
-
│ 2A │ 2B │ 2C │
|
|
49
|
-
└────┴────┴────┘
|
|
50
|
-
`);
|
|
51
|
-
});
|
|
52
|
-
});
|