table 6.0.5 → 6.0.9

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.
Files changed (61) hide show
  1. package/README.md +4 -4
  2. package/dist/alignString.js +6 -7
  3. package/dist/alignString.js.flow +5 -4
  4. package/dist/alignTableData.js +1 -2
  5. package/dist/calculateCellHeight.js +3 -4
  6. package/dist/calculateCellHeight.js.flow +2 -2
  7. package/dist/calculateCellWidthIndex.js +1 -2
  8. package/dist/calculateMaximumColumnWidthIndex.js +1 -2
  9. package/dist/calculateRowHeightIndex.js +6 -9
  10. package/dist/calculateRowHeightIndex.js.flow +5 -4
  11. package/dist/createStream.js +3 -6
  12. package/dist/createStream.js.flow +2 -3
  13. package/dist/drawBorder.js +1 -2
  14. package/dist/drawRow.js +1 -2
  15. package/dist/drawTable.js +1 -2
  16. package/dist/getBorderCharacters.js +1 -2
  17. package/dist/index.js +1 -2
  18. package/dist/makeConfig.js +9 -12
  19. package/dist/makeConfig.js.flow +6 -6
  20. package/dist/makeStreamConfig.js +8 -12
  21. package/dist/makeStreamConfig.js.flow +6 -6
  22. package/dist/mapDataUsingRowHeightIndex.js +4 -7
  23. package/dist/mapDataUsingRowHeightIndex.js.flow +3 -3
  24. package/dist/padTableData.js +1 -2
  25. package/dist/schemas/config.json +3 -0
  26. package/dist/stringifyTableData.js +1 -2
  27. package/dist/table.js +1 -2
  28. package/dist/truncateTableData.js +3 -4
  29. package/dist/truncateTableData.js.flow +2 -2
  30. package/dist/validateConfig.js +1 -4
  31. package/dist/validateConfig.js.flow +0 -1
  32. package/dist/validateTableData.js +1 -2
  33. package/dist/validators.js +201 -180
  34. package/dist/wrapCell.js +1 -2
  35. package/dist/wrapString.js +1 -2
  36. package/dist/wrapWord.js +1 -2
  37. package/package.json +27 -21
  38. package/dist/alignString.js.map +0 -1
  39. package/dist/alignTableData.js.map +0 -1
  40. package/dist/calculateCellHeight.js.map +0 -1
  41. package/dist/calculateCellWidthIndex.js.map +0 -1
  42. package/dist/calculateMaximumColumnWidthIndex.js.map +0 -1
  43. package/dist/calculateRowHeightIndex.js.map +0 -1
  44. package/dist/createStream.js.map +0 -1
  45. package/dist/drawBorder.js.map +0 -1
  46. package/dist/drawRow.js.map +0 -1
  47. package/dist/drawTable.js.map +0 -1
  48. package/dist/getBorderCharacters.js.map +0 -1
  49. package/dist/index.js.map +0 -1
  50. package/dist/makeConfig.js.map +0 -1
  51. package/dist/makeStreamConfig.js.map +0 -1
  52. package/dist/mapDataUsingRowHeightIndex.js.map +0 -1
  53. package/dist/padTableData.js.map +0 -1
  54. package/dist/stringifyTableData.js.map +0 -1
  55. package/dist/table.js.map +0 -1
  56. package/dist/truncateTableData.js.map +0 -1
  57. package/dist/validateConfig.js.map +0 -1
  58. package/dist/validateTableData.js.map +0 -1
  59. package/dist/wrapCell.js.map +0 -1
  60. package/dist/wrapString.js.map +0 -1
  61. package/dist/wrapWord.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  <a name="table"></a>
2
2
  # Table
3
3
 
4
- [![GitSpo Mentions](https://gitspo.com/badges/mentions/gajus/table?style=flat-square)](https://gitspo.com/mentions/gajus/table)
5
4
  [![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table)
6
5
  [![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table)
7
6
  [![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table)
@@ -56,8 +55,9 @@ npm install table
56
55
  Table data is described using an array (rows) of array (cells).
57
56
 
58
57
  ```js
59
- import tableImport from 'table';
60
- const { table } = tableImport;
58
+ import {
59
+ table
60
+ } from 'table';
61
61
 
62
62
  // Using commonjs?
63
63
  // const {table} = require('table');
@@ -487,7 +487,7 @@ table(data, config);
487
487
  | 2A | 2B | 2C |
488
488
  +----+----+----+
489
489
 
490
- # void (no borders; see "borderless table" section of the documentation)
490
+ # void (no borders; see "bordless table" section of the documentation)
491
491
 
492
492
  0A 0B 0C
493
493
 
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
8
+ var _isNumberObject = _interopRequireDefault(require("is-number-object"));
9
9
 
10
- var _isString2 = _interopRequireDefault(require("lodash/isString"));
10
+ var _isString = _interopRequireDefault(require("is-string"));
11
11
 
12
12
  var _stringWidth = _interopRequireDefault(require("string-width"));
13
13
 
@@ -63,11 +63,11 @@ const alignCenter = (subject, width) => {
63
63
 
64
64
 
65
65
  const alignString = (subject, containerWidth, alignment) => {
66
- if (!(0, _isString2.default)(subject)) {
66
+ if (!(0, _isString.default)(subject)) {
67
67
  throw new TypeError('Subject parameter value must be a string.');
68
68
  }
69
69
 
70
- if (!(0, _isNumber2.default)(containerWidth)) {
70
+ if (!(0, _isNumberObject.default)(containerWidth)) {
71
71
  throw new TypeError('Container width parameter value must be a number.');
72
72
  }
73
73
 
@@ -78,7 +78,7 @@ const alignString = (subject, containerWidth, alignment) => {
78
78
  throw new Error('Subject parameter value width cannot be greater than the container width.');
79
79
  }
80
80
 
81
- if (!(0, _isString2.default)(alignment)) {
81
+ if (!(0, _isString.default)(alignment)) {
82
82
  throw new TypeError('Alignment parameter value must be a string.');
83
83
  }
84
84
 
@@ -104,5 +104,4 @@ const alignString = (subject, containerWidth, alignment) => {
104
104
  };
105
105
 
106
106
  var _default = alignString;
107
- exports.default = _default;
108
- //# sourceMappingURL=alignString.js.map
107
+ exports.default = _default;
@@ -1,4 +1,5 @@
1
- import _ from 'lodash';
1
+ import isNumber from 'is-number-object';
2
+ import isString from 'is-string';
2
3
  import stringWidth from 'string-width';
3
4
 
4
5
  const alignments = [
@@ -54,11 +55,11 @@ const alignCenter = (subject, width) => {
54
55
  * @returns {string}
55
56
  */
56
57
  export default (subject, containerWidth, alignment) => {
57
- if (!_.isString(subject)) {
58
+ if (!isString(subject)) {
58
59
  throw new TypeError('Subject parameter value must be a string.');
59
60
  }
60
61
 
61
- if (!_.isNumber(containerWidth)) {
62
+ if (!isNumber(containerWidth)) {
62
63
  throw new TypeError('Container width parameter value must be a number.');
63
64
  }
64
65
 
@@ -70,7 +71,7 @@ export default (subject, containerWidth, alignment) => {
70
71
  throw new Error('Subject parameter value width cannot be greater than the container width.');
71
72
  }
72
73
 
73
- if (!_.isString(alignment)) {
74
+ if (!isString(alignment)) {
74
75
  throw new TypeError('Alignment parameter value must be a string.');
75
76
  }
76
77
 
@@ -31,5 +31,4 @@ const alignTableData = (rows, config) => {
31
31
  };
32
32
 
33
33
  var _default = alignTableData;
34
- exports.default = _default;
35
- //# sourceMappingURL=alignTableData.js.map
34
+ exports.default = _default;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _isString2 = _interopRequireDefault(require("lodash/isString"));
8
+ var _isString = _interopRequireDefault(require("is-string"));
9
9
 
10
10
  var _wrapCell = _interopRequireDefault(require("./wrapCell"));
11
11
 
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  * @returns {number}
19
19
  */
20
20
  const calculateCellHeight = (value, columnWidth, useWrapWord = false) => {
21
- if (!(0, _isString2.default)(value)) {
21
+ if (!(0, _isString.default)(value)) {
22
22
  throw new TypeError('Value must be a string.');
23
23
  }
24
24
 
@@ -34,5 +34,4 @@ const calculateCellHeight = (value, columnWidth, useWrapWord = false) => {
34
34
  };
35
35
 
36
36
  var _default = calculateCellHeight;
37
- exports.default = _default;
38
- //# sourceMappingURL=calculateCellHeight.js.map
37
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import isString from 'is-string';
2
2
  import wrapCell from './wrapCell';
3
3
 
4
4
  /**
@@ -8,7 +8,7 @@ import wrapCell from './wrapCell';
8
8
  * @returns {number}
9
9
  */
10
10
  export default (value, columnWidth, useWrapWord = false) => {
11
- if (!_.isString(value)) {
11
+ if (!isString(value)) {
12
12
  throw new TypeError('Value must be a string.');
13
13
  }
14
14
 
@@ -24,5 +24,4 @@ const calculateCellWidthIndex = cells => {
24
24
  };
25
25
 
26
26
  var _default = calculateCellWidthIndex;
27
- exports.default = _default;
28
- //# sourceMappingURL=calculateCellWidthIndex.js.map
27
+ exports.default = _default;
@@ -33,5 +33,4 @@ const calculateMaximumColumnWidthIndex = rows => {
33
33
  };
34
34
 
35
35
  var _default = calculateMaximumColumnWidthIndex;
36
- exports.default = _default;
37
- //# sourceMappingURL=calculateMaximumColumnWidthIndex.js.map
36
+ exports.default = _default;
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _max2 = _interopRequireDefault(require("lodash/max"));
8
+ var _isBooleanObject = _interopRequireDefault(require("is-boolean-object"));
9
9
 
10
- var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean"));
11
-
12
- var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
10
+ var _isNumberObject = _interopRequireDefault(require("is-number-object"));
13
11
 
14
12
  var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight"));
15
13
 
@@ -28,21 +26,20 @@ const calculateRowHeightIndex = (rows, config) => {
28
26
  rows.forEach(cells => {
29
27
  const cellHeightIndex = new Array(tableWidth).fill(1);
30
28
  cells.forEach((value, index1) => {
31
- if (!(0, _isNumber2.default)(config.columns[index1].width)) {
29
+ if (!(0, _isNumberObject.default)(config.columns[index1].width)) {
32
30
  throw new TypeError('column[index].width must be a number.');
33
31
  }
34
32
 
35
- if (!(0, _isBoolean2.default)(config.columns[index1].wrapWord)) {
33
+ if (!(0, _isBooleanObject.default)(config.columns[index1].wrapWord)) {
36
34
  throw new TypeError('column[index].wrapWord must be a boolean.');
37
35
  }
38
36
 
39
37
  cellHeightIndex[index1] = (0, _calculateCellHeight.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
40
38
  });
41
- rowSpanIndex.push((0, _max2.default)(cellHeightIndex));
39
+ rowSpanIndex.push(Math.max(...cellHeightIndex));
42
40
  });
43
41
  return rowSpanIndex;
44
42
  };
45
43
 
46
44
  var _default = calculateRowHeightIndex;
47
- exports.default = _default;
48
- //# sourceMappingURL=calculateRowHeightIndex.js.map
45
+ exports.default = _default;
@@ -1,4 +1,5 @@
1
- import _ from 'lodash';
1
+ import isBoolean from 'is-boolean-object';
2
+ import isNumber from 'is-number-object';
2
3
  import calculateCellHeight from './calculateCellHeight';
3
4
 
4
5
  /**
@@ -17,18 +18,18 @@ export default (rows, config) => {
17
18
  const cellHeightIndex = new Array(tableWidth).fill(1);
18
19
 
19
20
  cells.forEach((value, index1) => {
20
- if (!_.isNumber(config.columns[index1].width)) {
21
+ if (!isNumber(config.columns[index1].width)) {
21
22
  throw new TypeError('column[index].width must be a number.');
22
23
  }
23
24
 
24
- if (!_.isBoolean(config.columns[index1].wrapWord)) {
25
+ if (!isBoolean(config.columns[index1].wrapWord)) {
25
26
  throw new TypeError('column[index].wrapWord must be a boolean.');
26
27
  }
27
28
 
28
29
  cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
29
30
  });
30
31
 
31
- rowSpanIndex.push(_.max(cellHeightIndex));
32
+ rowSpanIndex.push(Math.max(...cellHeightIndex));
32
33
  });
33
34
 
34
35
  return rowSpanIndex;
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _mapValues2 = _interopRequireDefault(require("lodash/mapValues"));
9
-
10
8
  var _alignTableData = _interopRequireDefault(require("./alignTableData"));
11
9
 
12
10
  var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex"));
@@ -97,9 +95,9 @@ const append = (row, columnWidthIndex, config) => {
97
95
 
98
96
  const createStream = (userConfig = {}) => {
99
97
  const config = (0, _makeStreamConfig.default)(userConfig);
100
- const columnWidthIndex = Object.values((0, _mapValues2.default)(config.columns, column => {
98
+ const columnWidthIndex = Object.values(config.columns).map(column => {
101
99
  return column.width + column.paddingLeft + column.paddingRight;
102
- }));
100
+ });
103
101
  let empty;
104
102
  empty = true;
105
103
  return {
@@ -123,5 +121,4 @@ const createStream = (userConfig = {}) => {
123
121
  };
124
122
 
125
123
  var _default = createStream;
126
- exports.default = _default;
127
- //# sourceMappingURL=createStream.js.map
124
+ exports.default = _default;
@@ -1,4 +1,3 @@
1
- import _ from 'lodash';
2
1
  import alignTableData from './alignTableData';
3
2
  import calculateRowHeightIndex from './calculateRowHeightIndex';
4
3
  import {
@@ -96,9 +95,9 @@ const append = (row, columnWidthIndex, config) => {
96
95
  export default (userConfig = {}) => {
97
96
  const config = makeStreamConfig(userConfig);
98
97
 
99
- const columnWidthIndex = Object.values(_.mapValues(config.columns, (column) => {
98
+ const columnWidthIndex = Object.values(config.columns).map((column) => {
100
99
  return column.width + column.paddingLeft + column.paddingRight;
101
- }));
100
+ });
102
101
 
103
102
  let empty;
104
103
 
@@ -106,5 +106,4 @@ const drawBorderBottom = (columnSizeIndex, parts) => {
106
106
  });
107
107
  };
108
108
 
109
- exports.drawBorderBottom = drawBorderBottom;
110
- //# sourceMappingURL=drawBorder.js.map
109
+ exports.drawBorderBottom = drawBorderBottom;
package/dist/drawRow.js CHANGED
@@ -22,5 +22,4 @@ const drawRow = (columns, border) => {
22
22
  };
23
23
 
24
24
  var _default = drawRow;
25
- exports.default = _default;
26
- //# sourceMappingURL=drawRow.js.map
25
+ exports.default = _default;
package/dist/drawTable.js CHANGED
@@ -55,5 +55,4 @@ const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi
55
55
  };
56
56
 
57
57
  var _default = drawTable;
58
- exports.default = _default;
59
- //# sourceMappingURL=drawTable.js.map
58
+ exports.default = _default;
@@ -115,5 +115,4 @@ const getBorderCharacters = name => {
115
115
  };
116
116
 
117
117
  var _default = getBorderCharacters;
118
- exports.default = _default;
119
- //# sourceMappingURL=getBorderCharacters.js.map
118
+ exports.default = _default;
package/dist/index.js CHANGED
@@ -28,5 +28,4 @@ var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters
28
28
 
29
29
  var _table = _interopRequireDefault(require("./table"));
30
30
 
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
- //# sourceMappingURL=index.js.map
31
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
9
-
10
- var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
11
-
12
- var _times2 = _interopRequireDefault(require("lodash/times"));
8
+ var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
13
9
 
14
10
  var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));
15
11
 
@@ -41,8 +37,9 @@ const makeBorder = (border = {}) => {
41
37
 
42
38
  const makeColumns = (rows, columns = {}, columnDefault = {}) => {
43
39
  const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
44
- (0, _times2.default)(rows[0].length, index => {
45
- if ((0, _isUndefined2.default)(columns[index])) {
40
+
41
+ for (let index = 0; index < rows[0].length; index++) {
42
+ if (typeof columns[index] === 'undefined') {
46
43
  columns[index] = {};
47
44
  }
48
45
 
@@ -50,11 +47,12 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
50
47
  alignment: 'left',
51
48
  paddingLeft: 1,
52
49
  paddingRight: 1,
53
- truncate: Infinity,
50
+ truncate: Number.POSITIVE_INFINITY,
54
51
  width: maximumColumnWidthIndex[index],
55
52
  wrapWord: false
56
53
  }, columnDefault, columns[index]);
57
- });
54
+ }
55
+
58
56
  return columns;
59
57
  };
60
58
  /**
@@ -69,7 +67,7 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
69
67
 
70
68
  const makeConfig = (rows, userConfig = {}) => {
71
69
  (0, _validateConfig.default)('config.json', userConfig);
72
- const config = (0, _cloneDeep2.default)(userConfig);
70
+ const config = (0, _lodash.default)(userConfig);
73
71
  config.border = makeBorder(config.border);
74
72
  config.columns = makeColumns(rows, config.columns, config.columnDefault);
75
73
 
@@ -90,5 +88,4 @@ const makeConfig = (rows, userConfig = {}) => {
90
88
  };
91
89
 
92
90
  var _default = makeConfig;
93
- exports.default = _default;
94
- //# sourceMappingURL=makeConfig.js.map
91
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import cloneDeep from 'lodash.clonedeep';
2
2
  import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';
3
3
  import getBorderCharacters from './getBorderCharacters';
4
4
  import validateConfig from './validateConfig';
@@ -25,8 +25,8 @@ const makeBorder = (border = {}) => {
25
25
  const makeColumns = (rows, columns = {}, columnDefault = {}) => {
26
26
  const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);
27
27
 
28
- _.times(rows[0].length, (index) => {
29
- if (_.isUndefined(columns[index])) {
28
+ for (let index = 0; index < rows[0].length; index++) {
29
+ if (typeof columns[index] === 'undefined') {
30
30
  columns[index] = {};
31
31
  }
32
32
 
@@ -34,11 +34,11 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
34
34
  alignment: 'left',
35
35
  paddingLeft: 1,
36
36
  paddingRight: 1,
37
- truncate: Infinity,
37
+ truncate: Number.POSITIVE_INFINITY,
38
38
  width: maximumColumnWidthIndex[index],
39
39
  wrapWord: false,
40
40
  }, columnDefault, columns[index]);
41
- });
41
+ }
42
42
 
43
43
  return columns;
44
44
  };
@@ -54,7 +54,7 @@ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
54
54
  export default (rows, userConfig = {}) => {
55
55
  validateConfig('config.json', userConfig);
56
56
 
57
- const config = _.cloneDeep(userConfig);
57
+ const config = cloneDeep(userConfig);
58
58
 
59
59
  config.border = makeBorder(config.border);
60
60
  config.columns = makeColumns(rows, config.columns, config.columnDefault);
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
9
-
10
- var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
11
-
12
- var _times2 = _interopRequireDefault(require("lodash/times"));
8
+ var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
13
9
 
14
10
  var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
15
11
 
@@ -38,8 +34,8 @@ const makeBorder = (border = {}) => {
38
34
 
39
35
 
40
36
  const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
41
- (0, _times2.default)(columnCount, index => {
42
- if ((0, _isUndefined2.default)(columns[index])) {
37
+ for (let index = 0; index < columnCount; index++) {
38
+ if (typeof columns[index] === 'undefined') {
43
39
  columns[index] = {};
44
40
  }
45
41
 
@@ -47,10 +43,11 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
47
43
  alignment: 'left',
48
44
  paddingLeft: 1,
49
45
  paddingRight: 1,
50
- truncate: Infinity,
46
+ truncate: Number.POSITIVE_INFINITY,
51
47
  wrapWord: false
52
48
  }, columnDefault, columns[index]);
53
- });
49
+ }
50
+
54
51
  return columns;
55
52
  };
56
53
  /**
@@ -81,7 +78,7 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
81
78
 
82
79
  const makeStreamConfig = (userConfig = {}) => {
83
80
  (0, _validateConfig.default)('streamConfig.json', userConfig);
84
- const config = (0, _cloneDeep2.default)(userConfig);
81
+ const config = (0, _lodash.default)(userConfig);
85
82
 
86
83
  if (!config.columnDefault || !config.columnDefault.width) {
87
84
  throw new Error('Must provide config.columnDefault.width when creating a stream.');
@@ -97,5 +94,4 @@ const makeStreamConfig = (userConfig = {}) => {
97
94
  };
98
95
 
99
96
  var _default = makeStreamConfig;
100
- exports.default = _default;
101
- //# sourceMappingURL=makeStreamConfig.js.map
97
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import cloneDeep from 'lodash.clonedeep';
2
2
  import getBorderCharacters from './getBorderCharacters';
3
3
  import validateConfig from './validateConfig';
4
4
 
@@ -22,8 +22,8 @@ const makeBorder = (border = {}) => {
22
22
  * @returns {object}
23
23
  */
24
24
  const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
25
- _.times(columnCount, (index) => {
26
- if (_.isUndefined(columns[index])) {
25
+ for (let index = 0; index < columnCount; index++) {
26
+ if (typeof columns[index] === 'undefined') {
27
27
  columns[index] = {};
28
28
  }
29
29
 
@@ -31,10 +31,10 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
31
31
  alignment: 'left',
32
32
  paddingLeft: 1,
33
33
  paddingRight: 1,
34
- truncate: Infinity,
34
+ truncate: Number.POSITIVE_INFINITY,
35
35
  wrapWord: false,
36
36
  }, columnDefault, columns[index]);
37
- });
37
+ }
38
38
 
39
39
  return columns;
40
40
  };
@@ -66,7 +66,7 @@ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
66
66
  export default (userConfig = {}) => {
67
67
  validateConfig('streamConfig.json', userConfig);
68
68
 
69
- const config = _.cloneDeep(userConfig);
69
+ const config = cloneDeep(userConfig);
70
70
 
71
71
  if (!config.columnDefault || !config.columnDefault.width) {
72
72
  throw new Error('Must provide config.columnDefault.width when creating a stream.');
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
9
-
10
- var _times2 = _interopRequireDefault(require("lodash/times"));
8
+ var _lodash = _interopRequireDefault(require("lodash.flatten"));
11
9
 
12
10
  var _wrapCell = _interopRequireDefault(require("./wrapCell"));
13
11
 
@@ -22,7 +20,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
20
  const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
23
21
  const tableWidth = unmappedRows[0].length;
24
22
  const mappedRows = unmappedRows.map((cells, index0) => {
25
- const rowHeight = (0, _times2.default)(rowHeightIndex[index0], () => {
23
+ const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
26
24
  return new Array(tableWidth).fill('');
27
25
  }); // rowHeight
28
26
  // [{row index within rowSaw; index2}]
@@ -36,9 +34,8 @@ const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
36
34
  });
37
35
  return rowHeight;
38
36
  });
39
- return (0, _flatten2.default)(mappedRows);
37
+ return (0, _lodash.default)(mappedRows);
40
38
  };
41
39
 
42
40
  var _default = mapDataUsingRowHeightIndex;
43
- exports.default = _default;
44
- //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
41
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import flatten from 'lodash.flatten';
2
2
  import wrapCell from './wrapCell';
3
3
 
4
4
  /**
@@ -11,7 +11,7 @@ export default (unmappedRows, rowHeightIndex, config) => {
11
11
  const tableWidth = unmappedRows[0].length;
12
12
 
13
13
  const mappedRows = unmappedRows.map((cells, index0) => {
14
- const rowHeight = _.times(rowHeightIndex[index0], () => {
14
+ const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
15
15
  return new Array(tableWidth).fill('');
16
16
  });
17
17
 
@@ -30,5 +30,5 @@ export default (unmappedRows, rowHeightIndex, config) => {
30
30
  return rowHeight;
31
31
  });
32
32
 
33
- return _.flatten(mappedRows);
33
+ return flatten(mappedRows);
34
34
  };
@@ -20,5 +20,4 @@ const padTableData = (rows, config) => {
20
20
  };
21
21
 
22
22
  var _default = padTableData;
23
- exports.default = _default;
24
- //# sourceMappingURL=padTableData.js.map
23
+ exports.default = _default;
@@ -14,6 +14,9 @@
14
14
  },
15
15
  "drawHorizontalLine": {
16
16
  "typeof": "function"
17
+ },
18
+ "singleLine": {
19
+ "typeof": "boolean"
17
20
  }
18
21
  },
19
22
  "additionalProperties": false
@@ -18,5 +18,4 @@ const stringifyTableData = rows => {
18
18
  };
19
19
 
20
20
  var _default = stringifyTableData;
21
- exports.default = _default;
22
- //# sourceMappingURL=stringifyTableData.js.map
21
+ exports.default = _default;
package/dist/table.js CHANGED
@@ -106,5 +106,4 @@ const table = (data, userConfig = {}) => {
106
106
  };
107
107
 
108
108
  var _default = table;
109
- exports.default = _default;
110
- //# sourceMappingURL=table.js.map
109
+ exports.default = _default;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _truncate2 = _interopRequireDefault(require("lodash/truncate"));
8
+ var _lodash = _interopRequireDefault(require("lodash.truncate"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  const truncateTableData = (rows, config) => {
19
19
  return rows.map(cells => {
20
20
  return cells.map((content, index) => {
21
- return (0, _truncate2.default)(content, {
21
+ return (0, _lodash.default)(content, {
22
22
  length: config.columns[index].truncate
23
23
  });
24
24
  });
@@ -26,5 +26,4 @@ const truncateTableData = (rows, config) => {
26
26
  };
27
27
 
28
28
  var _default = truncateTableData;
29
- exports.default = _default;
30
- //# sourceMappingURL=truncateTableData.js.map
29
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import truncate from 'lodash.truncate';
2
2
 
3
3
  /**
4
4
  * @todo Make it work with ASCII content.
@@ -9,7 +9,7 @@ import _ from 'lodash';
9
9
  export default (rows, config) => {
10
10
  return rows.map((cells) => {
11
11
  return cells.map((content, index) => {
12
- return _.truncate(content, {
12
+ return truncate(content, {
13
13
  length: config.columns[index].truncate,
14
14
  });
15
15
  });
@@ -9,8 +9,6 @@ var _validators = _interopRequireDefault(require("../dist/validators"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- // eslint-disable-next-line import/default
13
-
14
12
  /**
15
13
  * @param {string} schemaId
16
14
  * @param {formatData~config} config
@@ -39,5 +37,4 @@ const validateConfig = (schemaId, config = {}) => {
39
37
  };
40
38
 
41
39
  var _default = validateConfig;
42
- exports.default = _default;
43
- //# sourceMappingURL=validateConfig.js.map
40
+ exports.default = _default;