table 4.0.2 → 4.0.3

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
@@ -454,7 +454,7 @@ output = table(data, {
454
454
  paddingLeft: 0,
455
455
  paddingRight: 1
456
456
  },
457
- drawJoin: () => {
457
+ drawHorizontalLine: () => {
458
458
  return false
459
459
  }
460
460
  });
@@ -22,7 +22,7 @@ const alignments = ['left', 'right', 'center'];
22
22
  * @returns {string}
23
23
  */
24
24
  const alignLeft = (subject, width) => {
25
- return subject + _lodash2.default.repeat(' ', width);
25
+ return subject + ' '.repeat(width);
26
26
  };
27
27
 
28
28
  /**
@@ -31,7 +31,7 @@ const alignLeft = (subject, width) => {
31
31
  * @returns {string}
32
32
  */
33
33
  const alignRight = (subject, width) => {
34
- return _lodash2.default.repeat(' ', width) + subject;
34
+ return ' '.repeat(width) + subject;
35
35
  };
36
36
 
37
37
  /**
@@ -45,11 +45,11 @@ const alignCenter = (subject, width) => {
45
45
  halfWidth = width / 2;
46
46
 
47
47
  if (halfWidth % 2 === 0) {
48
- return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth);
48
+ return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth);
49
49
  } else {
50
- halfWidth = _lodash2.default.floor(halfWidth);
50
+ halfWidth = Math.floor(halfWidth);
51
51
 
52
- return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth + 1);
52
+ return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1);
53
53
  }
54
54
  };
55
55
 
@@ -89,7 +89,7 @@ exports.default = (subject, containerWidth, alignment) => {
89
89
  }
90
90
 
91
91
  if (subjectWidth === 0) {
92
- return _lodash2.default.repeat(' ', containerWidth);
92
+ return ' '.repeat(containerWidth);
93
93
  }
94
94
 
95
95
  const availableWidth = containerWidth - subjectWidth;
@@ -31,7 +31,7 @@ exports.default = function (value, columnWidth) {
31
31
  throw new TypeError('Value must be a string.');
32
32
  }
33
33
 
34
- if (!_lodash2.default.isInteger(columnWidth)) {
34
+ if (!Number.isInteger(columnWidth)) {
35
35
  throw new TypeError('Column width must be an integer.');
36
36
  }
37
37
 
@@ -43,5 +43,5 @@ exports.default = function (value, columnWidth) {
43
43
  return (0, _wrapWord2.default)(value, columnWidth).length;
44
44
  }
45
45
 
46
- return _lodash2.default.ceil((0, _stringWidth2.default)(value) / columnWidth);
46
+ return Math.ceil((0, _stringWidth2.default)(value) / columnWidth);
47
47
  };
@@ -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 _calculateCellWidthIndex = require('./calculateCellWidthIndex');
12
8
 
13
9
  var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex);
@@ -25,12 +21,12 @@ exports.default = rows => {
25
21
  throw new Error('Dataset must have at least one row.');
26
22
  }
27
23
 
28
- const columns = _lodash2.default.fill(Array(rows[0].length), 0);
24
+ const columns = Array(rows[0].length).fill(0);
29
25
 
30
- _lodash2.default.forEach(rows, row => {
26
+ rows.forEach(row => {
31
27
  const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row);
32
28
 
33
- _lodash2.default.forEach(columnWidthIndex, (valueWidth, index0) => {
29
+ columnWidthIndex.forEach((valueWidth, index0) => {
34
30
  if (columns[index0] < valueWidth) {
35
31
  columns[index0] = valueWidth;
36
32
  }
@@ -26,10 +26,10 @@ exports.default = (rows, config) => {
26
26
 
27
27
  const rowSpanIndex = [];
28
28
 
29
- _lodash2.default.forEach(rows, cells => {
30
- const cellHeightIndex = _lodash2.default.fill(Array(tableWidth), 1);
29
+ rows.forEach(cells => {
30
+ const cellHeightIndex = Array(tableWidth).fill(1);
31
31
 
32
- _lodash2.default.forEach(cells, (value, index1) => {
32
+ cells.forEach((value, index1) => {
33
33
  if (!_lodash2.default.isNumber(config.columns[index1].width)) {
34
34
  throw new TypeError('column[index].width must be a number.');
35
35
  }
@@ -74,7 +74,7 @@ const prepareData = (data, config) => {
74
74
  const create = (row, columnWidthIndex, config) => {
75
75
  const rows = prepareData([row], config);
76
76
 
77
- const body = _lodash2.default.map(rows, literalRow => {
77
+ const body = rows.map(literalRow => {
78
78
  return (0, _drawRow2.default)(literalRow, config.border);
79
79
  }).join('');
80
80
 
@@ -100,7 +100,7 @@ const create = (row, columnWidthIndex, config) => {
100
100
  const append = (row, columnWidthIndex, config) => {
101
101
  const rows = prepareData([row], config);
102
102
 
103
- const body = _lodash2.default.map(rows, literalRow => {
103
+ const body = rows.map(literalRow => {
104
104
  return (0, _drawRow2.default)(literalRow, config.border);
105
105
  }).join('');
106
106
 
@@ -3,14 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = undefined;
7
-
8
- var _lodash = require('lodash');
9
-
10
- var _lodash2 = _interopRequireDefault(_lodash);
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
6
  /**
15
7
  * @typedef drawBorder~parts
16
8
  * @property {string} left
@@ -25,8 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
17
  * @returns {string}
26
18
  */
27
19
  const drawBorder = (columnSizeIndex, parts) => {
28
- const columns = _lodash2.default.map(columnSizeIndex, size => {
29
- return _lodash2.default.repeat(parts.body, size);
20
+ const columns = columnSizeIndex.map(size => {
21
+ return parts.body.repeat(size);
30
22
  }).join(parts.join);
31
23
 
32
24
  return parts.left + columns + parts.right + '\n';
package/dist/drawTable.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 _drawBorder = require('./drawBorder');
12
8
 
13
9
  var _drawRow = require('./drawRow');
@@ -39,7 +35,7 @@ exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLi
39
35
  output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
40
36
  }
41
37
 
42
- _lodash2.default.forEach(rows, (row, index0) => {
38
+ rows.forEach((row, index0) => {
43
39
  output += (0, _drawRow2.default)(row, border);
44
40
 
45
41
  if (!rowHeight) {
@@ -54,7 +54,7 @@ const makeColumns = function makeColumns(rows) {
54
54
  columns[index] = {};
55
55
  }
56
56
 
57
- columns[index] = _lodash2.default.assign({
57
+ columns[index] = Object.assign({
58
58
  alignment: 'left',
59
59
  paddingLeft: 1,
60
60
  paddingRight: 1,
@@ -29,14 +29,14 @@ exports.default = (unmappedRows, rowHeightIndex, config) => {
29
29
 
30
30
  const mappedRows = unmappedRows.map((cells, index0) => {
31
31
  const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => {
32
- return _lodash2.default.fill(Array(tableWidth), '');
32
+ return Array(tableWidth).fill('');
33
33
  });
34
34
 
35
35
  // rowHeight
36
36
  // [{row index within rowSaw; index2}]
37
37
  // [{cell index within a virtual row; index1}]
38
38
 
39
- _lodash2.default.forEach(cells, (value, index1) => {
39
+ cells.forEach((value, index1) => {
40
40
  let chunkedValue;
41
41
 
42
42
  if (config.columns[index1].wrapWord) {
@@ -45,7 +45,7 @@ exports.default = (unmappedRows, rowHeightIndex, config) => {
45
45
  chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width);
46
46
  }
47
47
 
48
- _lodash2.default.forEach(chunkedValue, (part, index2) => {
48
+ chunkedValue.forEach((part, index2) => {
49
49
  rowHeight[index2][index1] = part;
50
50
  });
51
51
  });
@@ -4,23 +4,17 @@ 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
  * @param {table~row[]} rows
15
9
  * @param {Object} config
16
10
  * @returns {table~row[]}
17
11
  */
18
12
  exports.default = (rows, config) => {
19
- return _lodash2.default.map(rows, cells => {
20
- return _lodash2.default.map(cells, (value, index1) => {
13
+ return rows.map(cells => {
14
+ return cells.map((value, index1) => {
21
15
  const column = config.columns[index1];
22
16
 
23
- return _lodash2.default.repeat(' ', column.paddingLeft) + value + _lodash2.default.repeat(' ', column.paddingRight);
17
+ return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
24
18
  });
25
19
  });
26
20
  };
@@ -17,8 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  * @returns {table~row[]}
18
18
  */
19
19
  exports.default = (rows, config) => {
20
- return _lodash2.default.map(rows, cells => {
21
- return _lodash2.default.map(cells, (content, index) => {
20
+ return rows.map(cells => {
21
+ return cells.map((content, index) => {
22
22
  return _lodash2.default.truncate(content, {
23
23
  length: config.columns[index].truncate
24
24
  });
@@ -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 _sliceAnsi = require('slice-ansi');
12
8
 
13
9
  var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi);
@@ -39,7 +35,7 @@ exports.default = (subject, size) => {
39
35
  do {
40
36
  chunks.push((0, _sliceAnsi2.default)(subjectSlice, 0, size));
41
37
 
42
- subjectSlice = _lodash2.default.trim((0, _sliceAnsi2.default)(subjectSlice, size));
38
+ subjectSlice = (0, _sliceAnsi2.default)(subjectSlice, size).trim();
43
39
  } while ((0, _stringWidth2.default)(subjectSlice));
44
40
 
45
41
  return chunks;
package/dist/wrapWord.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 _sliceAnsi = require('slice-ansi');
12
8
 
13
9
  var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi);
@@ -43,7 +39,7 @@ exports.default = (input, size) => {
43
39
 
44
40
  subject = (0, _sliceAnsi2.default)(subject, (0, _stringWidth2.default)(chunk));
45
41
 
46
- chunk = _lodash2.default.trim(chunk);
42
+ chunk = chunk.trim();
47
43
  } else {
48
44
  chunk = (0, _sliceAnsi2.default)(subject, 0, size);
49
45
  subject = (0, _sliceAnsi2.default)(subject, size);
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "http://gajus.com"
6
6
  },
7
7
  "dependencies": {
8
- "ajv": "^5.2.3",
9
- "ajv-keywords": "^2.1.0",
8
+ "ajv": "^6.0.1",
9
+ "ajv-keywords": "^3.0.0",
10
10
  "chalk": "^2.1.0",
11
11
  "lodash": "^4.17.4",
12
12
  "slice-ansi": "1.0.0",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "description": "Formats data into a string table.",
16
16
  "devDependencies": {
17
- "ajv-cli": "^2.1.0",
17
+ "ajv-cli": "^3.0.0",
18
18
  "babel": "^6.23.0",
19
19
  "babel-cli": "^6.26.0",
20
20
  "babel-core": "^6.26.0",
@@ -26,10 +26,13 @@
26
26
  "eslint-config-canonical": "^9.3.1",
27
27
  "gitdown": "^2.5.1",
28
28
  "husky": "^0.14.3",
29
- "mocha": "^3.5.3",
29
+ "mocha": "^5.0.0",
30
30
  "nyc": "^11.2.1",
31
31
  "sinon": "^4.0.0"
32
32
  },
33
+ "engines": {
34
+ "node": ">=4.0.0"
35
+ },
33
36
  "keywords": [
34
37
  "ascii",
35
38
  "text",
@@ -64,5 +67,5 @@
64
67
  "prepublish": "NODE_ENV=production npm run build",
65
68
  "test": "npm run build && nyc --check-coverage mocha"
66
69
  },
67
- "version": "4.0.2"
70
+ "version": "4.0.3"
68
71
  }