table 3.8.3 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
- <h1 id="table">Table</h1>
1
+ <a name="table"></a>
2
+ # Table
2
3
 
3
4
  [![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat)](https://travis-ci.org/gajus/table)
4
5
  [![NPM version](http://img.shields.io/npm/v/table.svg?style=flat)](https://www.npmjs.com/package/table)
@@ -22,7 +23,8 @@ Produces a string that represents array data in a text table.
22
23
 
23
24
  ![Demo of table displaying a list of missions to the Moon.](./.README/demo.png)
24
25
 
25
- <h2 id="table-features">Features</h2>
26
+ <a name="table-features"></a>
27
+ ## Features
26
28
 
27
29
  * Works with strings containing [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) characters.
28
30
  * Works with strings containing [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
@@ -32,12 +34,18 @@ Produces a string that represents array data in a text table.
32
34
  * Configurable column width.
33
35
  * Text wrapping.
34
36
 
35
- <h2 id="table-usage">Usage</h2>
37
+ <a name="table-usage"></a>
38
+ ## Usage
36
39
 
37
40
  Table data is described using an array (rows) of array (cells).
38
41
 
39
42
  ```js
40
- import table from 'table';
43
+ import {
44
+ table
45
+ } from 'table';
46
+
47
+ // Using commonjs?
48
+ // const {table} = require('table');
41
49
 
42
50
  let data,
43
51
  output;
@@ -125,7 +133,8 @@ console.log(output);
125
133
  ```
126
134
 
127
135
 
128
- <h3 id="table-usage-cell-content-alignment">Cell Content Alignment</h3>
136
+ <a name="table-usage-cell-content-alignment"></a>
137
+ ### Cell Content Alignment
129
138
 
130
139
  `{string} config.columns[{number}].alignment` property controls content horizontal alignment within a cell.
131
140
 
@@ -174,7 +183,8 @@ console.log(output);
174
183
  ╚════════════╧════════════╧════════════╝
175
184
  ```
176
185
 
177
- <h3 id="table-usage-column-width">Column Width</h3>
186
+ <a name="table-usage-column-width"></a>
187
+ ### Column Width
178
188
 
179
189
  `{number} config.columns[{number}].width` property restricts column width to a fixed width.
180
190
 
@@ -212,7 +222,8 @@ console.log(output);
212
222
  ╚════╧════════════╧════╝
213
223
  ```
214
224
 
215
- <h3 id="table-usage-custom-border">Custom Border</h3>
225
+ <a name="table-usage-custom-border"></a>
226
+ ### Custom Border
216
227
 
217
228
  `{object} config.border` property describes characters used to draw the table border.
218
229
 
@@ -265,7 +276,8 @@ console.log(output);
265
276
  └────┴────┴────┘
266
277
  ```
267
278
 
268
- <h3 id="table-usage-draw-horizontal-line">Draw Horizontal Line</h3>
279
+ <a name="table-usage-draw-horizontal-line"></a>
280
+ ### Draw Horizontal Line
269
281
 
270
282
  `{function} config.drawHorizontalLine` property is a function that is called for every non-content row in the table. The result of the function `{boolean}` determines whether a row is drawn.
271
283
 
@@ -311,7 +323,8 @@ console.log(output);
311
323
  ╚════╧════╧════╝
312
324
  ```
313
325
 
314
- <h3 id="table-usage-padding-cell-content">Padding Cell Content</h3>
326
+ <a name="table-usage-padding-cell-content"></a>
327
+ ### Padding Cell Content
315
328
 
316
329
  `{number} config.columns[{number}].paddingLeft` and `{number} config.columns[{number}].paddingRight` properties control content padding within a cell. Property value represents a number of whitespaces used to pad the content.
317
330
 
@@ -355,12 +368,14 @@ console.log(output);
355
368
  ╚══════╧══════╧════╝
356
369
  ```
357
370
 
358
- <h3 id="table-usage-predefined-border-templates">Predefined Border Templates</h3>
371
+ <a name="table-usage-predefined-border-templates"></a>
372
+ ### Predefined Border Templates
359
373
 
360
374
  You can load one of the predefined border templates using `getBorderCharacters` function.
361
375
 
362
376
  ```js
363
- import table, {
377
+ import {
378
+ table,
364
379
  getBorderCharacters
365
380
  } from 'table';
366
381
 
@@ -423,7 +438,8 @@ table(data, config);
423
438
 
424
439
  Raise [an issue](https://github.com/gajus/table/issues) if you'd like to contribute a new border template.
425
440
 
426
- <h4 id="table-usage-predefined-border-templates-borderless-table">Borderless Table</h4>
441
+ <a name="table-usage-predefined-border-templates-borderless-table"></a>
442
+ #### Borderless Table
427
443
 
428
444
  Simply using "void" border character template creates a table with a lot of unnecessary spacing.
429
445
 
@@ -452,7 +468,8 @@ console.log(output);
452
468
  2A 2B 2C
453
469
  ```
454
470
 
455
- <h3 id="table-usage-streaming">Streaming</h3>
471
+ <a name="table-usage-streaming"></a>
472
+ ### Streaming
456
473
 
457
474
  `table` package exports `createStream` function used to draw a table and append rows.
458
475
 
@@ -532,7 +549,8 @@ setInterval(() => {
532
549
  ```
533
550
 
534
551
  ![Streaming random data.](./.README/streaming-random.gif)
535
- <h3 id="table-usage-text-truncation">Text Truncation</h3>
552
+ <a name="table-usage-text-truncation"></a>
553
+ ### Text Truncation
536
554
 
537
555
  To handle a content that overflows the container width, `table` package implements [text wrapping](#table-usage-text-wrapping). However, sometimes you may want to truncate content that is too long to be displayed in the table.
538
556
 
@@ -571,7 +589,8 @@ console.log(output);
571
589
  ╚══════════════════════╝
572
590
  ```
573
591
 
574
- <h3 id="table-usage-text-wrapping">Text Wrapping</h3>
592
+ <a name="table-usage-text-wrapping"></a>
593
+ ### Text Wrapping
575
594
 
576
595
  `table` package implements auto text wrapping, i.e. text that has width greater than the container width will be separated into multiple lines, e.g.
577
596
 
@@ -103,6 +103,4 @@ exports.default = (subject, containerWidth, alignment) => {
103
103
  }
104
104
 
105
105
  return alignCenter(subject, availableWidth);
106
- };
107
-
108
- module.exports = exports['default'];
106
+ };
@@ -35,6 +35,4 @@ exports.default = (rows, config) => {
35
35
  }
36
36
  });
37
37
  });
38
- };
39
-
40
- module.exports = exports['default'];
38
+ };
@@ -44,6 +44,4 @@ exports.default = function (value, columnWidth) {
44
44
  }
45
45
 
46
46
  return _lodash2.default.ceil((0, _stringWidth2.default)(value) / columnWidth);
47
- };
48
-
49
- module.exports = exports['default'];
47
+ };
@@ -24,6 +24,4 @@ exports.default = cells => {
24
24
  return _lodash2.default.map(cells, value => {
25
25
  return (0, _stringWidth2.default)(value);
26
26
  });
27
- };
28
-
29
- module.exports = exports['default'];
27
+ };
@@ -38,6 +38,4 @@ exports.default = rows => {
38
38
  });
39
39
 
40
40
  return columns;
41
- };
42
-
43
- module.exports = exports['default'];
41
+ };
@@ -45,6 +45,4 @@ exports.default = (rows, config) => {
45
45
  });
46
46
 
47
47
  return rowSpanIndex;
48
- };
49
-
50
- module.exports = exports['default'];
48
+ };
@@ -154,6 +154,4 @@ exports.default = function () {
154
154
  }
155
155
  }
156
156
  };
157
- };
158
-
159
- module.exports = exports['default'];
157
+ };
package/dist/drawRow.js CHANGED
@@ -18,6 +18,4 @@ Object.defineProperty(exports, "__esModule", {
18
18
  */
19
19
  exports.default = (columns, border) => {
20
20
  return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n';
21
- };
22
-
23
- module.exports = exports['default'];
21
+ };
package/dist/drawTable.js CHANGED
@@ -58,6 +58,4 @@ exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi
58
58
  }
59
59
 
60
60
  return output;
61
- };
62
-
63
- module.exports = exports['default'];
61
+ };
@@ -123,6 +123,4 @@ exports.default = name => {
123
123
  }
124
124
 
125
125
  throw new Error('Unknown border template "' + name + '".');
126
- };
127
-
128
- module.exports = exports['default'];
126
+ };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
- exports.getBorderCharacters = exports.createStream = undefined;
6
+ exports.getBorderCharacters = exports.createStream = exports.table = undefined;
7
7
 
8
8
  var _table = require('./table');
9
9
 
@@ -19,6 +19,6 @@ var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
+ exports.table = _table2.default;
22
23
  exports.createStream = _createStream2.default;
23
- exports.getBorderCharacters = _getBorderCharacters2.default;
24
- exports.default = _table2.default;
24
+ exports.getBorderCharacters = _getBorderCharacters2.default;
@@ -96,6 +96,4 @@ exports.default = function (rows) {
96
96
  }
97
97
 
98
98
  return config;
99
- };
100
-
101
- module.exports = exports['default'];
99
+ };
@@ -104,6 +104,4 @@ exports.default = function () {
104
104
  config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
105
105
 
106
106
  return config;
107
- };
108
-
109
- module.exports = exports['default'];
107
+ };
@@ -54,6 +54,4 @@ exports.default = (unmappedRows, rowHeightIndex, config) => {
54
54
  });
55
55
 
56
56
  return _lodash2.default.flatten(mappedRows);
57
- };
58
-
59
- module.exports = exports['default'];
57
+ };
@@ -23,6 +23,4 @@ exports.default = (rows, config) => {
23
23
  return _lodash2.default.repeat(' ', column.paddingLeft) + value + _lodash2.default.repeat(' ', column.paddingRight);
24
24
  });
25
25
  });
26
- };
27
-
28
- module.exports = exports['default'];
26
+ };
@@ -20,6 +20,4 @@ exports.default = rows => {
20
20
  return _lodash2.default.map(rows, cells => {
21
21
  return _lodash2.default.map(cells, String);
22
22
  });
23
- };
24
-
25
- module.exports = exports['default'];
23
+ };
package/dist/table.js CHANGED
@@ -130,6 +130,4 @@ exports.default = function (data) {
130
130
  const cellWidthIndex = (0, _calculateCellWidthIndex2.default)(rows[0]);
131
131
 
132
132
  return (0, _drawTable2.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);
133
- };
134
-
135
- module.exports = exports['default'];
133
+ };
@@ -24,6 +24,4 @@ exports.default = (rows, config) => {
24
24
  });
25
25
  });
26
26
  });
27
- };
28
-
29
- module.exports = exports['default'];
27
+ };
@@ -54,6 +54,4 @@ exports.default = rows => {
54
54
  }
55
55
  });
56
56
  });
57
- };
58
-
59
- module.exports = exports['default'];
57
+ };
@@ -43,6 +43,4 @@ exports.default = (subject, size) => {
43
43
  } while ((0, _stringWidth2.default)(subjectSlice));
44
44
 
45
45
  return chunks;
46
- };
47
-
48
- module.exports = exports['default'];
46
+ };
package/dist/wrapWord.js CHANGED
@@ -53,6 +53,4 @@ exports.default = (input, size) => {
53
53
  } while ((0, _stringWidth2.default)(subject));
54
54
 
55
55
  return chunks;
56
- };
57
-
58
- module.exports = exports['default'];
56
+ };
package/package.json CHANGED
@@ -18,7 +18,6 @@
18
18
  "babel": "^6.5.2",
19
19
  "babel-cli": "^6.14.0",
20
20
  "babel-core": "^6.14.0",
21
- "babel-plugin-add-module-exports": "^0.2.1",
22
21
  "babel-plugin-istanbul": "^2.0.3",
23
22
  "babel-preset-es2015-node4": "^2.1.0",
24
23
  "babel-register": "^6.14.0",
@@ -57,7 +56,7 @@
57
56
  "url": "https://github.com/gajus/table"
58
57
  },
59
58
  "scripts": {
60
- "build": "rm -fr ./dist && babel --copy-files ./src --out-dir ./dist && npm run make-validators",
59
+ "build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run make-validators",
61
60
  "lint": "npm run build && eslint ./src ./tests",
62
61
  "make-readme": "gitdown ./.README/README.md --output-file ./README.md",
63
62
  "make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js",
@@ -65,5 +64,5 @@
65
64
  "prepublish": "NODE_ENV=production npm run build",
66
65
  "test": "npm run build && nyc --check-coverage mocha"
67
66
  },
68
- "version": "3.8.3"
67
+ "version": "4.0.1"
69
68
  }
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,7 +1,8 @@
1
1
  import _ from 'lodash';
2
2
  import chalk from 'chalk';
3
- import table, {
4
- getBorderCharacters
3
+ import {
4
+ table,
5
+ getBorderCharacters
5
6
  } from './../../../src';
6
7
 
7
8
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,6 +1,7 @@
1
1
  import _ from 'lodash';
2
- import table, {
3
- getBorderCharacters
2
+ import {
3
+ table,
4
+ getBorderCharacters
4
5
  } from './../../../src';
5
6
  import expectTable from './expectTable';
6
7
 
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -1,4 +1,6 @@
1
- import table from './../../../src';
1
+ import {
2
+ table
3
+ } from './../../../src';
2
4
  import expectTable from './expectTable';
3
5
 
4
6
  describe('README.md usage/', () => {
@@ -26,14 +26,14 @@ describe('wrapString', () => {
26
26
  });
27
27
  context('subject string contains ANSI escape codes', () => {
28
28
  describe('subject is lesser than the chunk size', () => {
29
- it('returns subject in a single chunk', () => {
29
+ it.skip('returns subject in a single chunk', () => {
30
30
  expect(wrapString(chalk.red('aaa'), 3)).to.deep.equal([
31
31
  '\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m'
32
32
  ]);
33
33
  });
34
34
  });
35
35
  describe('subject is larger than the chunk size', () => {
36
- it('returns subject sliced into multiple chunks', () => {
36
+ it.skip('returns subject sliced into multiple chunks', () => {
37
37
  expect(wrapString(chalk.red('aaabbbc'), 3)).to.deep.equal([
38
38
  '\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m',
39
39
  '\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31mbbb\u001b[39m',