table 4.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +10 -6
  3. package/dist/alignString.js +20 -20
  4. package/dist/alignString.js.flow +96 -0
  5. package/dist/alignString.js.map +1 -0
  6. package/dist/alignTableData.js +12 -11
  7. package/dist/alignTableData.js.flow +21 -0
  8. package/dist/alignTableData.js.map +1 -0
  9. package/dist/calculateCellHeight.js +14 -17
  10. package/dist/calculateCellHeight.js.flow +29 -0
  11. package/dist/calculateCellHeight.js.map +1 -0
  12. package/dist/calculateCellWidthIndex.js +10 -7
  13. package/dist/calculateCellWidthIndex.js.flow +13 -0
  14. package/dist/calculateCellWidthIndex.js.map +1 -0
  15. package/dist/calculateMaximumColumnWidthIndex.js +11 -11
  16. package/dist/calculateMaximumColumnWidthIndex.js.flow +27 -0
  17. package/dist/calculateMaximumColumnWidthIndex.js.map +1 -0
  18. package/dist/calculateRowHeightIndex.js +15 -19
  19. package/dist/calculateRowHeightIndex.js.flow +35 -0
  20. package/dist/calculateRowHeightIndex.js.map +1 -0
  21. package/dist/createStream.js +35 -68
  22. package/dist/createStream.js.flow +124 -0
  23. package/dist/createStream.js.map +1 -0
  24. package/dist/drawBorder.js +16 -8
  25. package/dist/drawBorder.js.flow +95 -0
  26. package/dist/drawBorder.js.map +1 -0
  27. package/dist/drawRow.js +8 -3
  28. package/dist/drawRow.js.flow +15 -0
  29. package/dist/drawRow.js.map +1 -0
  30. package/dist/drawTable.js +11 -12
  31. package/dist/drawTable.js.flow +52 -0
  32. package/dist/drawTable.js.map +1 -0
  33. package/dist/getBorderCharacters.js +8 -15
  34. package/dist/getBorderCharacters.js.flow +120 -0
  35. package/dist/getBorderCharacters.js.map +1 -0
  36. package/dist/index.js +23 -15
  37. package/dist/index.js.flow +9 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/makeConfig.js +21 -30
  40. package/dist/makeConfig.js.flow +72 -0
  41. package/dist/makeConfig.js.map +1 -0
  42. package/dist/makeStreamConfig.js +19 -27
  43. package/dist/makeStreamConfig.js.flow +83 -0
  44. package/dist/makeStreamConfig.js.map +1 -0
  45. package/dist/mapDataUsingRowHeightIndex.js +17 -22
  46. package/dist/mapDataUsingRowHeightIndex.js.flow +41 -0
  47. package/dist/mapDataUsingRowHeightIndex.js.map +1 -0
  48. package/dist/padTableData.js +8 -4
  49. package/dist/padTableData.js.flow +14 -0
  50. package/dist/padTableData.js.map +1 -0
  51. package/dist/schemas/config.json +1 -1
  52. package/dist/schemas/streamConfig.json +1 -1
  53. package/dist/stringifyTableData.js +7 -2
  54. package/dist/stringifyTableData.js.flow +11 -0
  55. package/dist/stringifyTableData.js.map +1 -0
  56. package/dist/table.js +29 -53
  57. package/dist/table.js.flow +95 -0
  58. package/dist/table.js.map +1 -0
  59. package/dist/truncateTableData.js +10 -7
  60. package/dist/truncateTableData.js.flow +17 -0
  61. package/dist/truncateTableData.js.map +1 -0
  62. package/dist/validateConfig.js +4 -5
  63. package/dist/validateConfig.js.flow +34 -0
  64. package/dist/validateConfig.js.map +1 -0
  65. package/dist/validateStreamConfig.js +4 -5
  66. package/dist/validateTableData.js +62 -15
  67. package/dist/validateTableData.js.flow +46 -0
  68. package/dist/validateTableData.js.map +1 -0
  69. package/dist/wrapString.js +13 -15
  70. package/dist/wrapString.js.flow +29 -0
  71. package/dist/wrapString.js.map +1 -0
  72. package/dist/wrapWord.js +15 -20
  73. package/dist/wrapWord.js.flow +39 -0
  74. package/dist/wrapWord.js.map +1 -0
  75. package/package.json +42 -30
@@ -0,0 +1,52 @@
1
+ import {
2
+ drawBorderTop,
3
+ drawBorderJoin,
4
+ drawBorderBottom
5
+ } from './drawBorder';
6
+ import drawRow from './drawRow';
7
+
8
+ /**
9
+ * @param {Array} rows
10
+ * @param {Object} border
11
+ * @param {Array} columnSizeIndex
12
+ * @param {Array} rowSpanIndex
13
+ * @param {Function} drawHorizontalLine
14
+ * @returns {string}
15
+ */
16
+ export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
17
+ let output;
18
+ let realRowIndex;
19
+ let rowHeight;
20
+
21
+ const rowCount = rows.length;
22
+
23
+ realRowIndex = 0;
24
+
25
+ output = '';
26
+
27
+ if (drawHorizontalLine(realRowIndex, rowCount)) {
28
+ output += drawBorderTop(columnSizeIndex, border);
29
+ }
30
+
31
+ rows.forEach((row, index0) => {
32
+ output += drawRow(row, border);
33
+
34
+ if (!rowHeight) {
35
+ rowHeight = rowSpanIndex[realRowIndex];
36
+
37
+ realRowIndex++;
38
+ }
39
+
40
+ rowHeight--;
41
+
42
+ if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
43
+ output += drawBorderJoin(columnSizeIndex, border);
44
+ }
45
+ });
46
+
47
+ if (drawHorizontalLine(realRowIndex, rowCount)) {
48
+ output += drawBorderBottom(columnSizeIndex, border);
49
+ }
50
+
51
+ return output;
52
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/drawTable.js"],"names":["rows","border","columnSizeIndex","rowSpanIndex","drawHorizontalLine","output","realRowIndex","rowHeight","rowCount","length","forEach","row","index0"],"mappings":";;;;;;;AAAA;;AAKA;;;;AAEA;;;;;;;;mBAQgBA,I,EAAMC,M,EAAQC,e,EAAiBC,Y,EAAcC,kB,KAAuB;AAClF,MAAIC,MAAJ;AACA,MAAIC,YAAJ;AACA,MAAIC,SAAJ;AAEA,QAAMC,QAAQ,GAAGR,IAAI,CAACS,MAAtB;AAEAH,EAAAA,YAAY,GAAG,CAAf;AAEAD,EAAAA,MAAM,GAAG,EAAT;;AAEA,MAAID,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAAtB,EAAgD;AAC9CH,IAAAA,MAAM,IAAI,+BAAcH,eAAd,EAA+BD,MAA/B,CAAV;AACD;;AAEDD,EAAAA,IAAI,CAACU,OAAL,CAAa,CAACC,GAAD,EAAMC,MAAN,KAAiB;AAC5BP,IAAAA,MAAM,IAAI,sBAAQM,GAAR,EAAaV,MAAb,CAAV;;AAEA,QAAI,CAACM,SAAL,EAAgB;AACdA,MAAAA,SAAS,GAAGJ,YAAY,CAACG,YAAD,CAAxB;AAEAA,MAAAA,YAAY;AACb;;AAEDC,IAAAA,SAAS;;AAET,QAAIA,SAAS,KAAK,CAAd,IAAmBK,MAAM,KAAKJ,QAAQ,GAAG,CAAzC,IAA8CJ,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAApE,EAA8F;AAC5FH,MAAAA,MAAM,IAAI,gCAAeH,eAAf,EAAgCD,MAAhC,CAAV;AACD;AACF,GAdD;;AAgBA,MAAIG,kBAAkB,CAACE,YAAD,EAAeE,QAAf,CAAtB,EAAgD;AAC9CH,IAAAA,MAAM,IAAI,kCAAiBH,eAAjB,EAAkCD,MAAlC,CAAV;AACD;;AAED,SAAOI,MAAP;AACD,C","sourcesContent":["import {\n drawBorderTop,\n drawBorderJoin,\n drawBorderBottom\n} from './drawBorder';\nimport drawRow from './drawRow';\n\n/**\n * @param {Array} rows\n * @param {Object} border\n * @param {Array} columnSizeIndex\n * @param {Array} rowSpanIndex\n * @param {Function} drawHorizontalLine\n * @returns {string}\n */\nexport default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {\n let output;\n let realRowIndex;\n let rowHeight;\n\n const rowCount = rows.length;\n\n realRowIndex = 0;\n\n output = '';\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderTop(columnSizeIndex, border);\n }\n\n rows.forEach((row, index0) => {\n output += drawRow(row, border);\n\n if (!rowHeight) {\n rowHeight = rowSpanIndex[realRowIndex];\n\n realRowIndex++;\n }\n\n rowHeight--;\n\n if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderJoin(columnSizeIndex, border);\n }\n });\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderBottom(columnSizeIndex, border);\n }\n\n return output;\n};\n"],"file":"drawTable.js"}
@@ -1,8 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
8
  /* eslint-disable sort-keys */
8
9
 
@@ -29,23 +30,20 @@ Object.defineProperty(exports, "__esModule", {
29
30
  * @param {string} name
30
31
  * @returns {border}
31
32
  */
32
- exports.default = name => {
33
+ const getBorderCharacters = name => {
33
34
  if (name === 'honeywell') {
34
35
  return {
35
36
  topBody: '═',
36
37
  topJoin: '╤',
37
38
  topLeft: '╔',
38
39
  topRight: '╗',
39
-
40
40
  bottomBody: '═',
41
41
  bottomJoin: '╧',
42
42
  bottomLeft: '╚',
43
43
  bottomRight: '╝',
44
-
45
44
  bodyLeft: '║',
46
45
  bodyRight: '║',
47
46
  bodyJoin: '│',
48
-
49
47
  joinBody: '─',
50
48
  joinLeft: '╟',
51
49
  joinRight: '╢',
@@ -59,16 +57,13 @@ exports.default = name => {
59
57
  topJoin: '┬',
60
58
  topLeft: '┌',
61
59
  topRight: '┐',
62
-
63
60
  bottomBody: '─',
64
61
  bottomJoin: '┴',
65
62
  bottomLeft: '└',
66
63
  bottomRight: '┘',
67
-
68
64
  bodyLeft: '│',
69
65
  bodyRight: '│',
70
66
  bodyJoin: '│',
71
-
72
67
  joinBody: '─',
73
68
  joinLeft: '├',
74
69
  joinRight: '┤',
@@ -82,16 +77,13 @@ exports.default = name => {
82
77
  topJoin: '+',
83
78
  topLeft: '+',
84
79
  topRight: '+',
85
-
86
80
  bottomBody: '-',
87
81
  bottomJoin: '+',
88
82
  bottomLeft: '+',
89
83
  bottomRight: '+',
90
-
91
84
  bodyLeft: '|',
92
85
  bodyRight: '|',
93
86
  bodyJoin: '|',
94
-
95
87
  joinBody: '-',
96
88
  joinLeft: '|',
97
89
  joinRight: '|',
@@ -105,16 +97,13 @@ exports.default = name => {
105
97
  topJoin: '',
106
98
  topLeft: '',
107
99
  topRight: '',
108
-
109
100
  bottomBody: '',
110
101
  bottomJoin: '',
111
102
  bottomLeft: '',
112
103
  bottomRight: '',
113
-
114
104
  bodyLeft: '',
115
105
  bodyRight: '',
116
106
  bodyJoin: '',
117
-
118
107
  joinBody: '',
119
108
  joinLeft: '',
120
109
  joinRight: '',
@@ -123,4 +112,8 @@ exports.default = name => {
123
112
  }
124
113
 
125
114
  throw new Error('Unknown border template "' + name + '".');
126
- };
115
+ };
116
+
117
+ var _default = getBorderCharacters;
118
+ exports.default = _default;
119
+ //# sourceMappingURL=getBorderCharacters.js.map
@@ -0,0 +1,120 @@
1
+ /* eslint-disable sort-keys */
2
+
3
+ /**
4
+ * @typedef border
5
+ * @property {string} topBody
6
+ * @property {string} topJoin
7
+ * @property {string} topLeft
8
+ * @property {string} topRight
9
+ * @property {string} bottomBody
10
+ * @property {string} bottomJoin
11
+ * @property {string} bottomLeft
12
+ * @property {string} bottomRight
13
+ * @property {string} bodyLeft
14
+ * @property {string} bodyRight
15
+ * @property {string} bodyJoin
16
+ * @property {string} joinBody
17
+ * @property {string} joinLeft
18
+ * @property {string} joinRight
19
+ * @property {string} joinJoin
20
+ */
21
+
22
+ /**
23
+ * @param {string} name
24
+ * @returns {border}
25
+ */
26
+ export default (name) => {
27
+ if (name === 'honeywell') {
28
+ return {
29
+ topBody: '═',
30
+ topJoin: '╤',
31
+ topLeft: '╔',
32
+ topRight: '╗',
33
+
34
+ bottomBody: '═',
35
+ bottomJoin: '╧',
36
+ bottomLeft: '╚',
37
+ bottomRight: '╝',
38
+
39
+ bodyLeft: '║',
40
+ bodyRight: '║',
41
+ bodyJoin: '│',
42
+
43
+ joinBody: '─',
44
+ joinLeft: '╟',
45
+ joinRight: '╢',
46
+ joinJoin: '┼'
47
+ };
48
+ }
49
+
50
+ if (name === 'norc') {
51
+ return {
52
+ topBody: '─',
53
+ topJoin: '┬',
54
+ topLeft: '┌',
55
+ topRight: '┐',
56
+
57
+ bottomBody: '─',
58
+ bottomJoin: '┴',
59
+ bottomLeft: '└',
60
+ bottomRight: '┘',
61
+
62
+ bodyLeft: '│',
63
+ bodyRight: '│',
64
+ bodyJoin: '│',
65
+
66
+ joinBody: '─',
67
+ joinLeft: '├',
68
+ joinRight: '┤',
69
+ joinJoin: '┼'
70
+ };
71
+ }
72
+
73
+ if (name === 'ramac') {
74
+ return {
75
+ topBody: '-',
76
+ topJoin: '+',
77
+ topLeft: '+',
78
+ topRight: '+',
79
+
80
+ bottomBody: '-',
81
+ bottomJoin: '+',
82
+ bottomLeft: '+',
83
+ bottomRight: '+',
84
+
85
+ bodyLeft: '|',
86
+ bodyRight: '|',
87
+ bodyJoin: '|',
88
+
89
+ joinBody: '-',
90
+ joinLeft: '|',
91
+ joinRight: '|',
92
+ joinJoin: '|'
93
+ };
94
+ }
95
+
96
+ if (name === 'void') {
97
+ return {
98
+ topBody: '',
99
+ topJoin: '',
100
+ topLeft: '',
101
+ topRight: '',
102
+
103
+ bottomBody: '',
104
+ bottomJoin: '',
105
+ bottomLeft: '',
106
+ bottomRight: '',
107
+
108
+ bodyLeft: '',
109
+ bodyRight: '',
110
+ bodyJoin: '',
111
+
112
+ joinBody: '',
113
+ joinLeft: '',
114
+ joinRight: '',
115
+ joinJoin: ''
116
+ };
117
+ }
118
+
119
+ throw new Error('Unknown border template "' + name + '".');
120
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/getBorderCharacters.js"],"names":["name","topBody","topJoin","topLeft","topRight","bottomBody","bottomJoin","bottomLeft","bottomRight","bodyLeft","bodyRight","bodyJoin","joinBody","joinLeft","joinRight","joinJoin","Error"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;;;;;;;;;;;AAmBA;;;;4BAIgBA,I,IAAS;AACvB,MAAIA,IAAI,KAAK,WAAb,EAA0B;AACxB,WAAO;AACLC,MAAAA,OAAO,EAAE,GADJ;AAELC,MAAAA,OAAO,EAAE,GAFJ;AAGLC,MAAAA,OAAO,EAAE,GAH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,UAAU,EAAE,GARP;AASLC,MAAAA,WAAW,EAAE,GATR;AAWLC,MAAAA,QAAQ,EAAE,GAXL;AAYLC,MAAAA,SAAS,EAAE,GAZN;AAaLC,MAAAA,QAAQ,EAAE,GAbL;AAeLC,MAAAA,QAAQ,EAAE,GAfL;AAgBLC,MAAAA,QAAQ,EAAE,GAhBL;AAiBLC,MAAAA,SAAS,EAAE,GAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,MAAIf,IAAI,KAAK,MAAb,EAAqB;AACnB,WAAO;AACLC,MAAAA,OAAO,EAAE,EADJ;AAELC,MAAAA,OAAO,EAAE,EAFJ;AAGLC,MAAAA,OAAO,EAAE,EAHJ;AAILC,MAAAA,QAAQ,EAAE,EAJL;AAMLC,MAAAA,UAAU,EAAE,EANP;AAOLC,MAAAA,UAAU,EAAE,EAPP;AAQLC,MAAAA,UAAU,EAAE,EARP;AASLC,MAAAA,WAAW,EAAE,EATR;AAWLC,MAAAA,QAAQ,EAAE,EAXL;AAYLC,MAAAA,SAAS,EAAE,EAZN;AAaLC,MAAAA,QAAQ,EAAE,EAbL;AAeLC,MAAAA,QAAQ,EAAE,EAfL;AAgBLC,MAAAA,QAAQ,EAAE,EAhBL;AAiBLC,MAAAA,SAAS,EAAE,EAjBN;AAkBLC,MAAAA,QAAQ,EAAE;AAlBL,KAAP;AAoBD;;AAED,QAAM,IAAIC,KAAJ,CAAU,8BAA8BhB,IAA9B,GAAqC,IAA/C,CAAN;AACD,C","sourcesContent":["/* eslint-disable sort-keys */\n\n/**\n * @typedef border\n * @property {string} topBody\n * @property {string} topJoin\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} bottomBody\n * @property {string} bottomJoin\n * @property {string} bottomLeft\n * @property {string} bottomRight\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n * @property {string} joinBody\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinJoin\n */\n\n/**\n * @param {string} name\n * @returns {border}\n */\nexport default (name) => {\n if (name === 'honeywell') {\n return {\n topBody: '═',\n topJoin: '╤',\n topLeft: '╔',\n topRight: '╗',\n\n bottomBody: '═',\n bottomJoin: '╧',\n bottomLeft: '╚',\n bottomRight: '╝',\n\n bodyLeft: '║',\n bodyRight: '║',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '╟',\n joinRight: '╢',\n joinJoin: '┼'\n };\n }\n\n if (name === 'norc') {\n return {\n topBody: '─',\n topJoin: '┬',\n topLeft: '┌',\n topRight: '┐',\n\n bottomBody: '─',\n bottomJoin: '┴',\n bottomLeft: '└',\n bottomRight: '┘',\n\n bodyLeft: '│',\n bodyRight: '│',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '├',\n joinRight: '┤',\n joinJoin: '┼'\n };\n }\n\n if (name === 'ramac') {\n return {\n topBody: '-',\n topJoin: '+',\n topLeft: '+',\n topRight: '+',\n\n bottomBody: '-',\n bottomJoin: '+',\n bottomLeft: '+',\n bottomRight: '+',\n\n bodyLeft: '|',\n bodyRight: '|',\n bodyJoin: '|',\n\n joinBody: '-',\n joinLeft: '|',\n joinRight: '|',\n joinJoin: '|'\n };\n }\n\n if (name === 'void') {\n return {\n topBody: '',\n topJoin: '',\n topLeft: '',\n topRight: '',\n\n bottomBody: '',\n bottomJoin: '',\n bottomLeft: '',\n bottomRight: '',\n\n bodyLeft: '',\n bodyRight: '',\n bodyJoin: '',\n\n joinBody: '',\n joinLeft: '',\n joinRight: '',\n joinJoin: ''\n };\n }\n\n throw new Error('Unknown border template \"' + name + '\".');\n};\n"],"file":"getBorderCharacters.js"}
package/dist/index.js CHANGED
@@ -1,24 +1,32 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getBorderCharacters = exports.createStream = exports.table = undefined;
7
-
8
- var _table = require('./table');
9
-
10
- var _table2 = _interopRequireDefault(_table);
11
-
12
- var _createStream = require('./createStream');
6
+ Object.defineProperty(exports, "table", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _table.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "createStream", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _createStream.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getBorderCharacters", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _getBorderCharacters.default;
22
+ }
23
+ });
13
24
 
14
- var _createStream2 = _interopRequireDefault(_createStream);
25
+ var _table = _interopRequireDefault(require("./table"));
15
26
 
16
- var _getBorderCharacters = require('./getBorderCharacters');
27
+ var _createStream = _interopRequireDefault(require("./createStream"));
17
28
 
18
- var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
29
+ var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
19
30
 
20
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- exports.table = _table2.default;
23
- exports.createStream = _createStream2.default;
24
- exports.getBorderCharacters = _getBorderCharacters2.default;
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import table from './table';
2
+ import createStream from './createStream';
3
+ import getBorderCharacters from './getBorderCharacters';
4
+
5
+ export {
6
+ table,
7
+ createStream,
8
+ getBorderCharacters
9
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["import table from './table';\nimport createStream from './createStream';\nimport getBorderCharacters from './getBorderCharacters';\n\nexport {\n table,\n createStream,\n getBorderCharacters\n};\n"],"file":"index.js"}
@@ -1,24 +1,17 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _lodash = require('lodash');
8
+ var _lodash = _interopRequireDefault(require("lodash"));
8
9
 
9
- var _lodash2 = _interopRequireDefault(_lodash);
10
+ var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
10
11
 
11
- var _getBorderCharacters = require('./getBorderCharacters');
12
+ var _validateConfig = _interopRequireDefault(require("./validateConfig"));
12
13
 
13
- var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
14
-
15
- var _validateConfig = require('./validateConfig');
16
-
17
- var _validateConfig2 = _interopRequireDefault(_validateConfig);
18
-
19
- var _calculateMaximumColumnWidthIndex = require('./calculateMaximumColumnWidthIndex');
20
-
21
- var _calculateMaximumColumnWidthIndex2 = _interopRequireDefault(_calculateMaximumColumnWidthIndex);
14
+ var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));
22
15
 
23
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
17
 
@@ -28,12 +21,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
21
  * @param {Object} border
29
22
  * @returns {Object}
30
23
  */
31
- const makeBorder = function makeBorder() {
32
- let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
-
34
- return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
24
+ const makeBorder = (border = {}) => {
25
+ return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
35
26
  };
36
-
37
27
  /**
38
28
  * Creates a configuration for every column using default
39
29
  * values for the missing configuration properties.
@@ -43,14 +33,13 @@ const makeBorder = function makeBorder() {
43
33
  * @param {Object} columnDefault
44
34
  * @returns {Object}
45
35
  */
46
- const makeColumns = function makeColumns(rows) {
47
- let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
48
- let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
49
36
 
50
- const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex2.default)(rows);
51
37
 
52
- _lodash2.default.times(rows[0].length, index => {
53
- if (_lodash2.default.isUndefined(columns[index])) {
38
+ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
39
+ const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
40
+
41
+ _lodash.default.times(rows[0].length, index => {
42
+ if (_lodash.default.isUndefined(columns[index])) {
54
43
  columns[index] = {};
55
44
  }
56
45
 
@@ -66,7 +55,6 @@ const makeColumns = function makeColumns(rows) {
66
55
 
67
56
  return columns;
68
57
  };
69
-
70
58
  /**
71
59
  * Makes a new configuration object out of the userConfig object
72
60
  * using default values for the missing configuration properties.
@@ -76,12 +64,11 @@ const makeColumns = function makeColumns(rows) {
76
64
  * @returns {Object}
77
65
  */
78
66
 
79
- exports.default = function (rows) {
80
- let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
81
67
 
82
- (0, _validateConfig2.default)('config.json', userConfig);
68
+ const makeConfig = (rows, userConfig = {}) => {
69
+ (0, _validateConfig.default)('config.json', userConfig);
83
70
 
84
- const config = _lodash2.default.cloneDeep(userConfig);
71
+ const config = _lodash.default.cloneDeep(userConfig);
85
72
 
86
73
  config.border = makeBorder(config.border);
87
74
  config.columns = makeColumns(rows, config.columns, config.columnDefault);
@@ -96,4 +83,8 @@ exports.default = function (rows) {
96
83
  }
97
84
 
98
85
  return config;
99
- };
86
+ };
87
+
88
+ var _default = makeConfig;
89
+ exports.default = _default;
90
+ //# sourceMappingURL=makeConfig.js.map
@@ -0,0 +1,72 @@
1
+ import _ from 'lodash';
2
+ import getBorderCharacters from './getBorderCharacters';
3
+ import validateConfig from './validateConfig';
4
+ import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';
5
+
6
+ /**
7
+ * Merges user provided border characters with the default border ("honeywell") characters.
8
+ *
9
+ * @param {Object} border
10
+ * @returns {Object}
11
+ */
12
+ const makeBorder = (border = {}) => {
13
+ return Object.assign({}, getBorderCharacters('honeywell'), border);
14
+ };
15
+
16
+ /**
17
+ * Creates a configuration for every column using default
18
+ * values for the missing configuration properties.
19
+ *
20
+ * @param {Array[]} rows
21
+ * @param {Object} columns
22
+ * @param {Object} columnDefault
23
+ * @returns {Object}
24
+ */
25
+ const makeColumns = (rows, columns = {}, columnDefault = {}) => {
26
+ const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);
27
+
28
+ _.times(rows[0].length, (index) => {
29
+ if (_.isUndefined(columns[index])) {
30
+ columns[index] = {};
31
+ }
32
+
33
+ columns[index] = Object.assign({
34
+ alignment: 'left',
35
+ paddingLeft: 1,
36
+ paddingRight: 1,
37
+ truncate: Infinity,
38
+ width: maximumColumnWidthIndex[index],
39
+ wrapWord: false
40
+ }, columnDefault, columns[index]);
41
+ });
42
+
43
+ return columns;
44
+ };
45
+
46
+ /**
47
+ * Makes a new configuration object out of the userConfig object
48
+ * using default values for the missing configuration properties.
49
+ *
50
+ * @param {Array[]} rows
51
+ * @param {Object} userConfig
52
+ * @returns {Object}
53
+ */
54
+ export default (rows, userConfig = {}) => {
55
+ validateConfig('config.json', userConfig);
56
+
57
+ const config = _.cloneDeep(userConfig);
58
+
59
+ config.border = makeBorder(config.border);
60
+ config.columns = makeColumns(rows, config.columns, config.columnDefault);
61
+
62
+ if (!config.drawHorizontalLine) {
63
+ /**
64
+ * @returns {boolean}
65
+ */
66
+ config.drawHorizontalLine = () => {
67
+ return true;
68
+ };
69
+ }
70
+
71
+ return config;
72
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/makeConfig.js"],"names":["makeBorder","border","Object","assign","makeColumns","rows","columns","columnDefault","maximumColumnWidthIndex","_","times","length","index","isUndefined","alignment","paddingLeft","paddingRight","truncate","Infinity","width","wrapWord","userConfig","config","cloneDeep","drawHorizontalLine"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA;;;;;;AAMA,MAAMA,UAAU,GAAG,CAACC,MAAM,GAAG,EAAV,KAAiB;AAClC,SAAOC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB,kCAAoB,WAApB,CAAlB,EAAoDF,MAAp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AGAF,IAAAA,MAAM,CAACE,kBAAP,GAA4B,MAAM;AAChC,aAAO,IAAP;AACD,KAFD;AAGD;;AAED,SAAOF,MAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\nimport calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nconst makeBorder = (border = {}) => {\n return Object.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nconst makeColumns = (rows, columns = {}, columnDefault = {}) => {\n const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);\n\n _.times(rows[0].length, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = Object.assign({\n alignment: 'left',\n paddingLeft: 1,\n paddingRight: 1,\n truncate: Infinity,\n width: maximumColumnWidthIndex[index],\n wrapWord: false\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (rows, userConfig = {}) => {\n validateConfig('config.json', userConfig);\n\n const config = _.cloneDeep(userConfig);\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(rows, config.columns, config.columnDefault);\n\n if (!config.drawHorizontalLine) {\n /**\n * @returns {boolean}\n */\n config.drawHorizontalLine = () => {\n return true;\n };\n }\n\n return config;\n};\n"],"file":"makeConfig.js"}
@@ -1,20 +1,15 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _lodash = require('lodash');
8
+ var _lodash = _interopRequireDefault(require("lodash"));
8
9
 
9
- var _lodash2 = _interopRequireDefault(_lodash);
10
+ var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
10
11
 
11
- var _getBorderCharacters = require('./getBorderCharacters');
12
-
13
- var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
14
-
15
- var _validateConfig = require('./validateConfig');
16
-
17
- var _validateConfig2 = _interopRequireDefault(_validateConfig);
12
+ var _validateConfig = _interopRequireDefault(require("./validateConfig"));
18
13
 
19
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
15
 
@@ -24,12 +19,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
19
  * @param {Object} border
25
20
  * @returns {Object}
26
21
  */
27
- const makeBorder = function makeBorder() {
28
- let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
29
-
30
- return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
22
+ const makeBorder = (border = {}) => {
23
+ return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
31
24
  };
32
-
33
25
  /**
34
26
  * Creates a configuration for every column using default
35
27
  * values for the missing configuration properties.
@@ -39,12 +31,11 @@ const makeBorder = function makeBorder() {
39
31
  * @param {Object} columnDefault
40
32
  * @returns {Object}
41
33
  */
42
- const makeColumns = function makeColumns(columnCount) {
43
- let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
44
- let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
45
34
 
46
- _lodash2.default.times(columnCount, index => {
47
- if (_lodash2.default.isUndefined(columns[index])) {
35
+
36
+ const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
37
+ _lodash.default.times(columnCount, index => {
38
+ if (_lodash.default.isUndefined(columns[index])) {
48
39
  columns[index] = {};
49
40
  }
50
41
 
@@ -59,7 +50,6 @@ const makeColumns = function makeColumns(columnCount) {
59
50
 
60
51
  return columns;
61
52
  };
62
-
63
53
  /**
64
54
  * @typedef {Object} columnConfig
65
55
  * @property {string} alignment
@@ -85,12 +75,11 @@ const makeColumns = function makeColumns(columnCount) {
85
75
  * @returns {Object}
86
76
  */
87
77
 
88
- exports.default = function () {
89
- let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90
78
 
91
- (0, _validateConfig2.default)('streamConfig.json', userConfig);
79
+ const makeStreamConfig = (userConfig = {}) => {
80
+ (0, _validateConfig.default)('streamConfig.json', userConfig);
92
81
 
93
- const config = _lodash2.default.cloneDeep(userConfig);
82
+ const config = _lodash.default.cloneDeep(userConfig);
94
83
 
95
84
  if (!config.columnDefault || !config.columnDefault.width) {
96
85
  throw new Error('Must provide config.columnDefault.width when creating a stream.');
@@ -102,6 +91,9 @@ exports.default = function () {
102
91
 
103
92
  config.border = makeBorder(config.border);
104
93
  config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
105
-
106
94
  return config;
107
- };
95
+ };
96
+
97
+ var _default = makeStreamConfig;
98
+ exports.default = _default;
99
+ //# sourceMappingURL=makeStreamConfig.js.map