table 6.7.1 → 6.7.5

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 (62) hide show
  1. package/dist/{alignString.d.ts → src/alignString.d.ts} +0 -0
  2. package/dist/{alignString.js → src/alignString.js} +4 -3
  3. package/dist/{alignTableData.d.ts → src/alignTableData.d.ts} +0 -0
  4. package/dist/{alignTableData.js → src/alignTableData.js} +2 -1
  5. package/dist/{calculateCellHeight.d.ts → src/calculateCellHeight.d.ts} +0 -0
  6. package/dist/{calculateCellHeight.js → src/calculateCellHeight.js} +2 -1
  7. package/dist/{calculateCellWidths.d.ts → src/calculateCellWidths.d.ts} +0 -0
  8. package/dist/{calculateCellWidths.js → src/calculateCellWidths.js} +1 -0
  9. package/dist/{calculateColumnWidths.d.ts → src/calculateColumnWidths.d.ts} +0 -0
  10. package/dist/{calculateColumnWidths.js → src/calculateColumnWidths.js} +2 -1
  11. package/dist/{calculateRowHeights.d.ts → src/calculateRowHeights.d.ts} +0 -0
  12. package/dist/{calculateRowHeights.js → src/calculateRowHeights.js} +2 -1
  13. package/dist/{createStream.d.ts → src/createStream.d.ts} +0 -0
  14. package/dist/{createStream.js → src/createStream.js} +14 -13
  15. package/dist/{drawBorder.d.ts → src/drawBorder.d.ts} +3 -3
  16. package/dist/{drawBorder.js → src/drawBorder.js} +2 -1
  17. package/dist/{drawContent.d.ts → src/drawContent.d.ts} +0 -0
  18. package/dist/{drawContent.js → src/drawContent.js} +1 -0
  19. package/dist/{drawHeader.d.ts → src/drawHeader.d.ts} +0 -0
  20. package/dist/{drawHeader.js → src/drawHeader.js} +7 -6
  21. package/dist/{drawRow.d.ts → src/drawRow.d.ts} +0 -0
  22. package/dist/{drawRow.js → src/drawRow.js} +2 -1
  23. package/dist/{drawTable.d.ts → src/drawTable.d.ts} +0 -0
  24. package/dist/{drawTable.js → src/drawTable.js} +7 -6
  25. package/dist/{generated → src/generated}/validators.d.ts +0 -0
  26. package/dist/{generated → src/generated}/validators.js +5 -4
  27. package/dist/{getBorderCharacters.d.ts → src/getBorderCharacters.d.ts} +0 -0
  28. package/dist/{getBorderCharacters.js → src/getBorderCharacters.js} +1 -0
  29. package/dist/{index.d.ts → src/index.d.ts} +0 -0
  30. package/dist/{index.js → src/index.js} +1 -0
  31. package/dist/{makeStreamConfig.d.ts → src/makeStreamConfig.d.ts} +1 -1
  32. package/dist/{makeStreamConfig.js → src/makeStreamConfig.js} +4 -8
  33. package/dist/{makeTableConfig.d.ts → src/makeTableConfig.d.ts} +1 -1
  34. package/dist/{makeTableConfig.js → src/makeTableConfig.js} +5 -6
  35. package/dist/{mapDataUsingRowHeights.d.ts → src/mapDataUsingRowHeights.d.ts} +0 -0
  36. package/dist/{mapDataUsingRowHeights.js → src/mapDataUsingRowHeights.js} +2 -1
  37. package/dist/{padTableData.d.ts → src/padTableData.d.ts} +0 -0
  38. package/dist/{padTableData.js → src/padTableData.js} +2 -1
  39. package/dist/{stringifyTableData.d.ts → src/stringifyTableData.d.ts} +0 -0
  40. package/dist/{stringifyTableData.js → src/stringifyTableData.js} +2 -1
  41. package/dist/{table.d.ts → src/table.d.ts} +0 -0
  42. package/dist/src/table.js +27 -0
  43. package/dist/{truncateTableData.d.ts → src/truncateTableData.d.ts} +0 -0
  44. package/dist/{truncateTableData.js → src/truncateTableData.js} +3 -2
  45. package/dist/{types → src/types}/api.d.ts +0 -0
  46. package/dist/{types → src/types}/api.js +1 -0
  47. package/dist/{types → src/types}/internal.d.ts +0 -0
  48. package/dist/{types → src/types}/internal.js +1 -0
  49. package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
  50. package/dist/{utils.js → src/utils.js} +4 -3
  51. package/dist/{validateConfig.d.ts → src/validateConfig.d.ts} +0 -0
  52. package/dist/{validateConfig.js → src/validateConfig.js} +2 -0
  53. package/dist/{validateTableData.d.ts → src/validateTableData.d.ts} +0 -0
  54. package/dist/{validateTableData.js → src/validateTableData.js} +2 -1
  55. package/dist/{wrapCell.d.ts → src/wrapCell.d.ts} +0 -0
  56. package/dist/{wrapCell.js → src/wrapCell.js} +4 -3
  57. package/dist/{wrapString.d.ts → src/wrapString.d.ts} +0 -0
  58. package/dist/{wrapString.js → src/wrapString.js} +4 -3
  59. package/dist/{wrapWord.d.ts → src/wrapWord.d.ts} +0 -0
  60. package/dist/{wrapWord.js → src/wrapWord.js} +5 -4
  61. package/package.json +17 -33
  62. package/dist/table.js +0 -26
File without changes
@@ -16,11 +16,11 @@ const alignCenter = (subject, width) => {
16
16
  return ' '.repeat(Math.floor(width / 2)) + subject + ' '.repeat(Math.ceil(width / 2));
17
17
  };
18
18
  const alignJustify = (subject, width) => {
19
- const spaceSequenceCount = utils_1.countSpaceSequence(subject);
19
+ const spaceSequenceCount = (0, utils_1.countSpaceSequence)(subject);
20
20
  if (spaceSequenceCount === 0) {
21
21
  return alignLeft(subject, width);
22
22
  }
23
- const addingSpaces = utils_1.distributeUnevenly(width, spaceSequenceCount);
23
+ const addingSpaces = (0, utils_1.distributeUnevenly)(width, spaceSequenceCount);
24
24
  if (Math.max(...addingSpaces) > 3) {
25
25
  return alignLeft(subject, width);
26
26
  }
@@ -34,7 +34,7 @@ const alignJustify = (subject, width) => {
34
34
  * text in a desired alignment within a container.
35
35
  */
36
36
  const alignString = (subject, containerWidth, alignment) => {
37
- const subjectWidth = string_width_1.default(subject);
37
+ const subjectWidth = (0, string_width_1.default)(subject);
38
38
  if (subjectWidth === containerWidth) {
39
39
  return subject;
40
40
  }
@@ -57,3 +57,4 @@ const alignString = (subject, containerWidth, alignment) => {
57
57
  return alignCenter(subject, availableWidth);
58
58
  };
59
59
  exports.alignString = alignString;
60
+ //# sourceMappingURL=alignString.js.map
@@ -6,8 +6,9 @@ const alignTableData = (rows, config) => {
6
6
  return rows.map((row) => {
7
7
  return row.map((cell, cellIndex) => {
8
8
  const { width, alignment } = config.columns[cellIndex];
9
- return alignString_1.alignString(cell, width, alignment);
9
+ return (0, alignString_1.alignString)(cell, width, alignment);
10
10
  });
11
11
  });
12
12
  };
13
13
  exports.alignTableData = alignTableData;
14
+ //# sourceMappingURL=alignTableData.js.map
@@ -6,6 +6,7 @@ const wrapCell_1 = require("./wrapCell");
6
6
  * Calculates height of cell content in regard to its width and word wrapping.
7
7
  */
8
8
  const calculateCellHeight = (value, columnWidth, useWrapWord = false) => {
9
- return wrapCell_1.wrapCell(value, columnWidth, useWrapWord).length;
9
+ return (0, wrapCell_1.wrapCell)(value, columnWidth, useWrapWord).length;
10
10
  };
11
11
  exports.calculateCellHeight = calculateCellHeight;
12
+ //# sourceMappingURL=calculateCellHeight.js.map
@@ -14,3 +14,4 @@ const calculateCellWidths = (cells) => {
14
14
  });
15
15
  };
16
16
  exports.calculateCellWidths = calculateCellWidths;
17
+ //# sourceMappingURL=calculateCellWidths.js.map
@@ -7,10 +7,11 @@ const calculateCellWidths_1 = require("./calculateCellWidths");
7
7
  exports.default = (rows) => {
8
8
  const columnWidths = new Array(rows[0].length).fill(0);
9
9
  rows.forEach((row) => {
10
- const cellWidths = calculateCellWidths_1.calculateCellWidths(row);
10
+ const cellWidths = (0, calculateCellWidths_1.calculateCellWidths)(row);
11
11
  cellWidths.forEach((cellWidth, cellIndex) => {
12
12
  columnWidths[cellIndex] = Math.max(columnWidths[cellIndex], cellWidth);
13
13
  });
14
14
  });
15
15
  return columnWidths;
16
16
  };
17
+ //# sourceMappingURL=calculateColumnWidths.js.map
@@ -9,10 +9,11 @@ const calculateRowHeights = (rows, config) => {
9
9
  return rows.map((row) => {
10
10
  let rowHeight = 1;
11
11
  row.forEach((cell, cellIndex) => {
12
- const cellHeight = calculateCellHeight_1.calculateCellHeight(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord);
12
+ const cellHeight = (0, calculateCellHeight_1.calculateCellHeight)(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord);
13
13
  rowHeight = Math.max(rowHeight, cellHeight);
14
14
  });
15
15
  return rowHeight;
16
16
  });
17
17
  };
18
18
  exports.calculateRowHeights = calculateRowHeights;
19
+ //# sourceMappingURL=calculateRowHeights.js.map
@@ -11,45 +11,45 @@ const padTableData_1 = require("./padTableData");
11
11
  const stringifyTableData_1 = require("./stringifyTableData");
12
12
  const truncateTableData_1 = require("./truncateTableData");
13
13
  const prepareData = (data, config) => {
14
- let rows = stringifyTableData_1.stringifyTableData(data);
15
- rows = truncateTableData_1.truncateTableData(rows, config);
16
- const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config);
17
- rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config);
18
- rows = alignTableData_1.alignTableData(rows, config);
19
- rows = padTableData_1.padTableData(rows, config);
14
+ let rows = (0, stringifyTableData_1.stringifyTableData)(data);
15
+ rows = (0, truncateTableData_1.truncateTableData)(rows, config);
16
+ const rowHeights = (0, calculateRowHeights_1.calculateRowHeights)(rows, config);
17
+ rows = (0, mapDataUsingRowHeights_1.mapDataUsingRowHeights)(rows, rowHeights, config);
18
+ rows = (0, alignTableData_1.alignTableData)(rows, config);
19
+ rows = (0, padTableData_1.padTableData)(rows, config);
20
20
  return rows;
21
21
  };
22
22
  const create = (row, columnWidths, config) => {
23
23
  const rows = prepareData([row], config);
24
24
  const body = rows.map((literalRow) => {
25
- return drawRow_1.drawRow(literalRow, config);
25
+ return (0, drawRow_1.drawRow)(literalRow, config);
26
26
  }).join('');
27
27
  let output;
28
28
  output = '';
29
- output += drawBorder_1.drawBorderTop(columnWidths, config);
29
+ output += (0, drawBorder_1.drawBorderTop)(columnWidths, config);
30
30
  output += body;
31
- output += drawBorder_1.drawBorderBottom(columnWidths, config);
31
+ output += (0, drawBorder_1.drawBorderBottom)(columnWidths, config);
32
32
  output = output.trimEnd();
33
33
  process.stdout.write(output);
34
34
  };
35
35
  const append = (row, columnWidths, config) => {
36
36
  const rows = prepareData([row], config);
37
37
  const body = rows.map((literalRow) => {
38
- return drawRow_1.drawRow(literalRow, config);
38
+ return (0, drawRow_1.drawRow)(literalRow, config);
39
39
  }).join('');
40
40
  let output = '';
41
- const bottom = drawBorder_1.drawBorderBottom(columnWidths, config);
41
+ const bottom = (0, drawBorder_1.drawBorderBottom)(columnWidths, config);
42
42
  if (bottom !== '\n') {
43
43
  output = '\r\u001B[K';
44
44
  }
45
- output += drawBorder_1.drawBorderJoin(columnWidths, config);
45
+ output += (0, drawBorder_1.drawBorderJoin)(columnWidths, config);
46
46
  output += body;
47
47
  output += bottom;
48
48
  output = output.trimEnd();
49
49
  process.stdout.write(output);
50
50
  };
51
51
  const createStream = (userConfig) => {
52
- const config = makeStreamConfig_1.makeStreamConfig(userConfig);
52
+ const config = (0, makeStreamConfig_1.makeStreamConfig)(userConfig);
53
53
  const columnWidths = Object.values(config.columns).map((column) => {
54
54
  return column.width + column.paddingLeft + column.paddingRight;
55
55
  });
@@ -70,3 +70,4 @@ const createStream = (userConfig) => {
70
70
  };
71
71
  };
72
72
  exports.createStream = createStream;
73
+ //# sourceMappingURL=createStream.js.map
@@ -1,14 +1,14 @@
1
1
  import type { DrawVerticalLine } from './types/api';
2
2
  import type { TableConfig, SeparatorGetter, TopBorderConfig, JoinBorderConfig, BottomBorderConfig } from './types/internal';
3
3
  declare type Separator = {
4
- readonly left: string;
5
- readonly right: string;
6
4
  readonly body: string;
7
5
  readonly join: string;
6
+ readonly left: string;
7
+ readonly right: string;
8
8
  };
9
9
  declare const drawBorder: (columnWidths: number[], config: {
10
- separator: Separator;
11
10
  drawVerticalLine: DrawVerticalLine;
11
+ separator: Separator;
12
12
  }) => string;
13
13
  declare const drawBorderTop: (columnWidths: number[], config: {
14
14
  border: TopBorderConfig;
@@ -7,7 +7,7 @@ const drawBorder = (columnWidths, config) => {
7
7
  const columns = columnWidths.map((size) => {
8
8
  return config.separator.body.repeat(size);
9
9
  });
10
- return drawContent_1.drawContent(columns, {
10
+ return (0, drawContent_1.drawContent)(columns, {
11
11
  drawSeparator: drawVerticalLine,
12
12
  separatorGetter: (index, columnCount) => {
13
13
  if (index === 0) {
@@ -98,3 +98,4 @@ const createTableBorderGetter = (columnWidths, config) => {
98
98
  };
99
99
  };
100
100
  exports.createTableBorderGetter = createTableBorderGetter;
101
+ //# sourceMappingURL=drawBorder.js.map
File without changes
@@ -24,3 +24,4 @@ const drawContent = (contents, separatorConfig) => {
24
24
  return result.join('');
25
25
  };
26
26
  exports.drawContent = drawContent;
27
+ //# sourceMappingURL=drawContent.js.map
File without changes
@@ -11,13 +11,13 @@ const drawHeader = (width, config) => {
11
11
  throw new Error('Can not draw header without header configuration');
12
12
  }
13
13
  const { alignment, paddingRight, paddingLeft, wrapWord } = config.header;
14
- let content = config.header.content;
15
- content = truncateTableData_1.truncateString(content, config.header.truncate);
16
- const headerLines = wrapCell_1.wrapCell(content, width, wrapWord);
14
+ let { content } = config.header;
15
+ content = (0, truncateTableData_1.truncateString)(content, config.header.truncate);
16
+ const headerLines = (0, wrapCell_1.wrapCell)(content, width, wrapWord);
17
17
  return headerLines.map((headerLine) => {
18
- let line = alignString_1.alignString(headerLine, width, alignment);
19
- line = padTableData_1.padString(line, paddingLeft, paddingRight);
20
- return drawRow_1.drawRow([line], {
18
+ let line = (0, alignString_1.alignString)(headerLine, width, alignment);
19
+ line = (0, padTableData_1.padString)(line, paddingLeft, paddingRight);
20
+ return (0, drawRow_1.drawRow)([line], {
21
21
  ...config,
22
22
  drawVerticalLine: (index) => {
23
23
  const columnCount = config.columns.length;
@@ -27,3 +27,4 @@ const drawHeader = (width, config) => {
27
27
  }).join('');
28
28
  };
29
29
  exports.drawHeader = drawHeader;
30
+ //# sourceMappingURL=drawHeader.js.map
File without changes
@@ -4,7 +4,7 @@ exports.drawRow = void 0;
4
4
  const drawContent_1 = require("./drawContent");
5
5
  const drawRow = (row, config) => {
6
6
  const { border, drawVerticalLine } = config;
7
- return drawContent_1.drawContent(row, {
7
+ return (0, drawContent_1.drawContent)(row, {
8
8
  drawSeparator: drawVerticalLine,
9
9
  separatorGetter: (index, columnCount) => {
10
10
  if (index === 0) {
@@ -18,3 +18,4 @@ const drawRow = (row, config) => {
18
18
  }) + '\n';
19
19
  };
20
20
  exports.drawRow = drawRow;
21
+ //# sourceMappingURL=drawRow.js.map
File without changes
@@ -12,19 +12,19 @@ const drawRow_1 = require("./drawRow");
12
12
  const utils_1 = require("./utils");
13
13
  const drawTable = (rows, columnWidths, rowHeights, config) => {
14
14
  const { drawHorizontalLine, singleLine, } = config;
15
- const contents = utils_1.groupBySizes(rows, rowHeights).map((group) => {
15
+ const contents = (0, utils_1.groupBySizes)(rows, rowHeights).map((group) => {
16
16
  return group.map((row) => {
17
- return drawRow_1.drawRow(row, config);
17
+ return (0, drawRow_1.drawRow)(row, config);
18
18
  }).join('');
19
19
  });
20
20
  if (config.header) {
21
21
  // assume that topLeft/right border have width = 1
22
- const headerWidth = string_width_1.default(drawRow_1.drawRow(rows[0], config)) - 2 -
22
+ const headerWidth = (0, string_width_1.default)((0, drawRow_1.drawRow)(rows[0], config)) - 2 -
23
23
  config.header.paddingLeft - config.header.paddingRight;
24
- const header = drawHeader_1.drawHeader(headerWidth, config);
24
+ const header = (0, drawHeader_1.drawHeader)(headerWidth, config);
25
25
  contents.unshift(header);
26
26
  }
27
- return drawContent_1.drawContent(contents, {
27
+ return (0, drawContent_1.drawContent)(contents, {
28
28
  drawSeparator: (index, size) => {
29
29
  // Top/bottom border
30
30
  if (index === 0 || index === size) {
@@ -32,7 +32,8 @@ const drawTable = (rows, columnWidths, rowHeights, config) => {
32
32
  }
33
33
  return !singleLine && drawHorizontalLine(index, size);
34
34
  },
35
- separatorGetter: drawBorder_1.createTableBorderGetter(columnWidths, config),
35
+ separatorGetter: (0, drawBorder_1.createTableBorderGetter)(columnWidths, config),
36
36
  });
37
37
  };
38
38
  exports.drawTable = drawTable;
39
+ //# sourceMappingURL=drawTable.js.map
@@ -1313,7 +1313,7 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
1313
1313
  schemaPath: "#/properties/drawVerticalLine/typeof",
1314
1314
  keyword: "typeof",
1315
1315
  params: {},
1316
- message: "should pass \"typeof\" keyword validation"
1316
+ message: "must pass \"typeof\" keyword validation"
1317
1317
  };
1318
1318
  if (vErrors === null) {
1319
1319
  vErrors = [err9];
@@ -1331,7 +1331,7 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
1331
1331
  schemaPath: "#/properties/drawHorizontalLine/typeof",
1332
1332
  keyword: "typeof",
1333
1333
  params: {},
1334
- message: "should pass \"typeof\" keyword validation"
1334
+ message: "must pass \"typeof\" keyword validation"
1335
1335
  };
1336
1336
  if (vErrors === null) {
1337
1337
  vErrors = [err10];
@@ -1349,7 +1349,7 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
1349
1349
  schemaPath: "#/properties/singleLine/typeof",
1350
1350
  keyword: "typeof",
1351
1351
  params: {},
1352
- message: "should pass \"typeof\" keyword validation"
1352
+ message: "must pass \"typeof\" keyword validation"
1353
1353
  };
1354
1354
  if (vErrors === null) {
1355
1355
  vErrors = [err11];
@@ -2135,7 +2135,7 @@ function validate76(data, { instancePath = "", parentData, parentDataProperty, r
2135
2135
  schemaPath: "#/properties/drawVerticalLine/typeof",
2136
2136
  keyword: "typeof",
2137
2137
  params: {},
2138
- message: "should pass \"typeof\" keyword validation"
2138
+ message: "must pass \"typeof\" keyword validation"
2139
2139
  };
2140
2140
  if (vErrors === null) {
2141
2141
  vErrors = [err5];
@@ -2168,3 +2168,4 @@ function validate76(data, { instancePath = "", parentData, parentDataProperty, r
2168
2168
  validate76.errors = vErrors;
2169
2169
  return errors === 0;
2170
2170
  }
2171
+ //# sourceMappingURL=validators.js.map
@@ -86,3 +86,4 @@ const getBorderCharacters = (name) => {
86
86
  throw new Error('Unknown border template "' + name + '".');
87
87
  };
88
88
  exports.getBorderCharacters = getBorderCharacters;
89
+ //# sourceMappingURL=getBorderCharacters.js.map
File without changes
@@ -18,3 +18,4 @@ Object.defineProperty(exports, "getBorderCharacters", { enumerable: true, get: f
18
18
  const table_1 = require("./table");
19
19
  Object.defineProperty(exports, "table", { enumerable: true, get: function () { return table_1.table; } });
20
20
  __exportStar(require("./types/api"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -4,4 +4,4 @@ import type { StreamConfig } from './types/internal';
4
4
  * Makes a new configuration object out of the userConfig object
5
5
  * using default values for the missing configuration properties.
6
6
  */
7
- export declare const makeStreamConfig: (userConfig: StreamUserConfig) => StreamConfig;
7
+ export declare const makeStreamConfig: (config: StreamUserConfig) => StreamConfig;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.makeStreamConfig = void 0;
7
- const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
8
4
  const utils_1 = require("./utils");
9
5
  const validateConfig_1 = require("./validateConfig");
10
6
  /**
@@ -29,9 +25,8 @@ const makeColumnsConfig = (columnCount, columns = {}, columnDefault) => {
29
25
  * Makes a new configuration object out of the userConfig object
30
26
  * using default values for the missing configuration properties.
31
27
  */
32
- const makeStreamConfig = (userConfig) => {
33
- validateConfig_1.validateConfig('streamConfig.json', userConfig);
34
- const config = lodash_clonedeep_1.default(userConfig);
28
+ const makeStreamConfig = (config) => {
29
+ (0, validateConfig_1.validateConfig)('streamConfig.json', config);
35
30
  if (config.columnDefault.width === undefined) {
36
31
  throw new Error('Must provide config.columnDefault.width when creating a stream.');
37
32
  }
@@ -40,8 +35,9 @@ const makeStreamConfig = (userConfig) => {
40
35
  return true;
41
36
  },
42
37
  ...config,
43
- border: utils_1.makeBorderConfig(config.border),
38
+ border: (0, utils_1.makeBorderConfig)(config.border),
44
39
  columns: makeColumnsConfig(config.columnCount, config.columns, config.columnDefault),
45
40
  };
46
41
  };
47
42
  exports.makeStreamConfig = makeStreamConfig;
43
+ //# sourceMappingURL=makeStreamConfig.js.map
@@ -4,4 +4,4 @@ import type { Row, TableConfig } from './types/internal';
4
4
  * Makes a new configuration object out of the userConfig object
5
5
  * using default values for the missing configuration properties.
6
6
  */
7
- export declare const makeTableConfig: (rows: Row[], userConfig?: TableUserConfig) => TableConfig;
7
+ export declare const makeTableConfig: (rows: Row[], config?: TableUserConfig) => TableConfig;
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeTableConfig = void 0;
7
- const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
8
7
  const calculateColumnWidths_1 = __importDefault(require("./calculateColumnWidths"));
9
8
  const utils_1 = require("./utils");
10
9
  const validateConfig_1 = require("./validateConfig");
@@ -13,7 +12,7 @@ const validateConfig_1 = require("./validateConfig");
13
12
  * values for the missing configuration properties.
14
13
  */
15
14
  const makeColumnsConfig = (rows, columns, columnDefault) => {
16
- const columnWidths = calculateColumnWidths_1.default(rows);
15
+ const columnWidths = (0, calculateColumnWidths_1.default)(rows);
17
16
  return rows[0].map((_, columnIndex) => {
18
17
  return {
19
18
  alignment: 'left',
@@ -45,13 +44,12 @@ const makeHeaderConfig = (config) => {
45
44
  * Makes a new configuration object out of the userConfig object
46
45
  * using default values for the missing configuration properties.
47
46
  */
48
- const makeTableConfig = (rows, userConfig = {}) => {
47
+ const makeTableConfig = (rows, config = {}) => {
49
48
  var _a, _b, _c;
50
- validateConfig_1.validateConfig('config.json', userConfig);
51
- const config = lodash_clonedeep_1.default(userConfig);
49
+ (0, validateConfig_1.validateConfig)('config.json', config);
52
50
  return {
53
51
  ...config,
54
- border: utils_1.makeBorderConfig(config.border),
52
+ border: (0, utils_1.makeBorderConfig)(config.border),
55
53
  columns: makeColumnsConfig(rows, config.columns, config.columnDefault),
56
54
  drawHorizontalLine: (_a = config.drawHorizontalLine) !== null && _a !== void 0 ? _a : (() => {
57
55
  return true;
@@ -64,3 +62,4 @@ const makeTableConfig = (rows, userConfig = {}) => {
64
62
  };
65
63
  };
66
64
  exports.makeTableConfig = makeTableConfig;
65
+ //# sourceMappingURL=makeTableConfig.js.map
@@ -31,7 +31,7 @@ const mapDataUsingRowHeights = (unmappedRows, rowHeights, config) => {
31
31
  return new Array(tableWidth).fill('');
32
32
  });
33
33
  unmappedRow.forEach((cell, cellIndex) => {
34
- const cellLines = wrapCell_1.wrapCell(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord);
34
+ const cellLines = (0, wrapCell_1.wrapCell)(cell, config.columns[cellIndex].width, config.columns[cellIndex].wrapWord);
35
35
  const paddedCellLines = padCellVertically(cellLines, outputRowHeight, config.columns[cellIndex]);
36
36
  paddedCellLines.forEach((cellLine, cellLineIndex) => {
37
37
  outputRow[cellLineIndex][cellIndex] = cellLine;
@@ -42,3 +42,4 @@ const mapDataUsingRowHeights = (unmappedRows, rowHeights, config) => {
42
42
  return flatten(mappedRows);
43
43
  };
44
44
  exports.mapDataUsingRowHeights = mapDataUsingRowHeights;
45
+ //# sourceMappingURL=mapDataUsingRowHeights.js.map
@@ -9,8 +9,9 @@ const padTableData = (rows, config) => {
9
9
  return rows.map((cells) => {
10
10
  return cells.map((cell, cellIndex) => {
11
11
  const { paddingLeft, paddingRight } = config.columns[cellIndex];
12
- return exports.padString(cell, paddingLeft, paddingRight);
12
+ return (0, exports.padString)(cell, paddingLeft, paddingRight);
13
13
  });
14
14
  });
15
15
  };
16
16
  exports.padTableData = padTableData;
17
+ //# sourceMappingURL=padTableData.js.map
@@ -5,8 +5,9 @@ const utils_1 = require("./utils");
5
5
  const stringifyTableData = (rows) => {
6
6
  return rows.map((cells) => {
7
7
  return cells.map((cell) => {
8
- return utils_1.normalizeString(String(cell));
8
+ return (0, utils_1.normalizeString)(String(cell));
9
9
  });
10
10
  });
11
11
  };
12
12
  exports.stringifyTableData = stringifyTableData;
13
+ //# sourceMappingURL=stringifyTableData.js.map
File without changes
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.table = void 0;
4
+ const alignTableData_1 = require("./alignTableData");
5
+ const calculateCellWidths_1 = require("./calculateCellWidths");
6
+ const calculateRowHeights_1 = require("./calculateRowHeights");
7
+ const drawTable_1 = require("./drawTable");
8
+ const makeTableConfig_1 = require("./makeTableConfig");
9
+ const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights");
10
+ const padTableData_1 = require("./padTableData");
11
+ const stringifyTableData_1 = require("./stringifyTableData");
12
+ const truncateTableData_1 = require("./truncateTableData");
13
+ const validateTableData_1 = require("./validateTableData");
14
+ const table = (data, userConfig = {}) => {
15
+ (0, validateTableData_1.validateTableData)(data);
16
+ let rows = (0, stringifyTableData_1.stringifyTableData)(data);
17
+ const config = (0, makeTableConfig_1.makeTableConfig)(rows, userConfig);
18
+ rows = (0, truncateTableData_1.truncateTableData)(rows, config);
19
+ const rowHeights = (0, calculateRowHeights_1.calculateRowHeights)(rows, config);
20
+ rows = (0, mapDataUsingRowHeights_1.mapDataUsingRowHeights)(rows, rowHeights, config);
21
+ rows = (0, alignTableData_1.alignTableData)(rows, config);
22
+ rows = (0, padTableData_1.padTableData)(rows, config);
23
+ const cellWidths = (0, calculateCellWidths_1.calculateCellWidths)(rows[0]);
24
+ return (0, drawTable_1.drawTable)(rows, cellWidths, rowHeights, config);
25
+ };
26
+ exports.table = table;
27
+ //# sourceMappingURL=table.js.map
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.truncateTableData = exports.truncateString = void 0;
7
7
  const lodash_truncate_1 = __importDefault(require("lodash.truncate"));
8
8
  const truncateString = (input, length) => {
9
- return lodash_truncate_1.default(input, { length,
9
+ return (0, lodash_truncate_1.default)(input, { length,
10
10
  omission: '…' });
11
11
  };
12
12
  exports.truncateString = truncateString;
@@ -16,8 +16,9 @@ exports.truncateString = truncateString;
16
16
  const truncateTableData = (rows, config) => {
17
17
  return rows.map((cells) => {
18
18
  return cells.map((cell, cellIndex) => {
19
- return exports.truncateString(cell, config.columns[cellIndex].truncate);
19
+ return (0, exports.truncateString)(cell, config.columns[cellIndex].truncate);
20
20
  });
21
21
  });
22
22
  };
23
23
  exports.truncateTableData = truncateTableData;
24
+ //# sourceMappingURL=truncateTableData.js.map
File without changes
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api.js.map
File without changes
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=internal.js.map
File without changes
@@ -23,11 +23,11 @@ exports.normalizeString = normalizeString;
23
23
  * @internal
24
24
  */
25
25
  const splitAnsi = (input) => {
26
- const lengths = strip_ansi_1.default(input).split('\n').map(string_width_1.default);
26
+ const lengths = (0, strip_ansi_1.default)(input).split('\n').map(string_width_1.default);
27
27
  const result = [];
28
28
  let startIndex = 0;
29
29
  lengths.forEach((length) => {
30
- result.push(length === 0 ? '' : slice_ansi_1.default(input, startIndex, startIndex + length));
30
+ result.push(length === 0 ? '' : (0, slice_ansi_1.default)(input, startIndex, startIndex + length));
31
31
  // Plus 1 for the newline character itself
32
32
  startIndex += length + 1;
33
33
  });
@@ -41,7 +41,7 @@ exports.splitAnsi = splitAnsi;
41
41
  */
42
42
  const makeBorderConfig = (border) => {
43
43
  return {
44
- ...getBorderCharacters_1.getBorderCharacters('honeywell'),
44
+ ...(0, getBorderCharacters_1.getBorderCharacters)('honeywell'),
45
45
  ...border,
46
46
  };
47
47
  };
@@ -90,3 +90,4 @@ const distributeUnevenly = (sum, length) => {
90
90
  });
91
91
  };
92
92
  exports.distributeUnevenly = distributeUnevenly;
93
+ //# sourceMappingURL=utils.js.map
@@ -8,6 +8,7 @@ const validators_1 = __importDefault(require("./generated/validators"));
8
8
  const validateConfig = (schemaId, config) => {
9
9
  const validate = validators_1.default[schemaId];
10
10
  if (!validate(config) && validate.errors) {
11
+ // eslint-disable-next-line promise/prefer-await-to-callbacks
11
12
  const errors = validate.errors.map((error) => {
12
13
  return {
13
14
  message: error.message,
@@ -23,3 +24,4 @@ const validateConfig = (schemaId, config) => {
23
24
  }
24
25
  };
25
26
  exports.validateConfig = validateConfig;
27
+ //# sourceMappingURL=validateConfig.js.map
@@ -22,10 +22,11 @@ const validateTableData = (rows) => {
22
22
  }
23
23
  for (const cell of row) {
24
24
  // eslint-disable-next-line no-control-regex
25
- if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(utils_1.normalizeString(String(cell)))) {
25
+ if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test((0, utils_1.normalizeString)(String(cell)))) {
26
26
  throw new Error('Table data must not contain control characters.');
27
27
  }
28
28
  }
29
29
  }
30
30
  };
31
31
  exports.validateTableData = validateTableData;
32
+ //# sourceMappingURL=validateTableData.js.map
File without changes
@@ -13,15 +13,15 @@ const wrapWord_1 = require("./wrapWord");
13
13
  */
14
14
  const wrapCell = (cellValue, cellWidth, useWrapWord) => {
15
15
  // First split on literal newlines
16
- const cellLines = utils_1.splitAnsi(cellValue);
16
+ const cellLines = (0, utils_1.splitAnsi)(cellValue);
17
17
  // Then iterate over the list and word-wrap every remaining line if necessary.
18
18
  for (let lineNr = 0; lineNr < cellLines.length;) {
19
19
  let lineChunks;
20
20
  if (useWrapWord) {
21
- lineChunks = wrapWord_1.wrapWord(cellLines[lineNr], cellWidth);
21
+ lineChunks = (0, wrapWord_1.wrapWord)(cellLines[lineNr], cellWidth);
22
22
  }
23
23
  else {
24
- lineChunks = wrapString_1.wrapString(cellLines[lineNr], cellWidth);
24
+ lineChunks = (0, wrapString_1.wrapString)(cellLines[lineNr], cellWidth);
25
25
  }
26
26
  // Replace our original array element with whatever the wrapping returned
27
27
  cellLines.splice(lineNr, 1, ...lineChunks);
@@ -30,3 +30,4 @@ const wrapCell = (cellValue, cellWidth, useWrapWord) => {
30
30
  return cellLines;
31
31
  };
32
32
  exports.wrapCell = wrapCell;
33
+ //# sourceMappingURL=wrapCell.js.map
File without changes
@@ -18,9 +18,10 @@ const wrapString = (subject, size) => {
18
18
  let subjectSlice = subject;
19
19
  const chunks = [];
20
20
  do {
21
- chunks.push(slice_ansi_1.default(subjectSlice, 0, size));
22
- subjectSlice = slice_ansi_1.default(subjectSlice, size).trim();
23
- } while (string_width_1.default(subjectSlice));
21
+ chunks.push((0, slice_ansi_1.default)(subjectSlice, 0, size));
22
+ subjectSlice = (0, slice_ansi_1.default)(subjectSlice, size).trim();
23
+ } while ((0, string_width_1.default)(subjectSlice));
24
24
  return chunks;
25
25
  };
26
26
  exports.wrapString = wrapString;
27
+ //# sourceMappingURL=wrapString.js.map
File without changes
@@ -7,10 +7,10 @@ exports.wrapWord = void 0;
7
7
  const slice_ansi_1 = __importDefault(require("slice-ansi"));
8
8
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
9
  const calculateStringLengths = (input, size) => {
10
- let subject = strip_ansi_1.default(input);
10
+ let subject = (0, strip_ansi_1.default)(input);
11
11
  const chunks = [];
12
12
  // https://regex101.com/r/gY5kZ1/1
13
- const re = new RegExp('(^.{1,' + String(size) + '}(\\s+|$))|(^.{1,' + String(size - 1) + '}(\\\\|/|_|\\.|,|;|-))');
13
+ const re = new RegExp('(^.{1,' + String(Math.max(size, 1)) + '}(\\s+|$))|(^.{1,' + String(Math.max(2, size - 1) - 1) + '}(\\\\|/|_|\\.|,|;|-))');
14
14
  do {
15
15
  let chunk;
16
16
  const match = re.exec(subject);
@@ -32,10 +32,11 @@ const calculateStringLengths = (input, size) => {
32
32
  const wrapWord = (input, size) => {
33
33
  const result = [];
34
34
  let startIndex = 0;
35
- calculateStringLengths(input, size).forEach(([length, offset]) => {
36
- result.push(slice_ansi_1.default(input, startIndex, startIndex + length));
35
+ calculateStringLengths(input, Math.max(size, 1)).forEach(([length, offset]) => {
36
+ result.push((0, slice_ansi_1.default)(input, startIndex, startIndex + length));
37
37
  startIndex += length + offset;
38
38
  });
39
39
  return result;
40
40
  };
41
41
  exports.wrapWord = wrapWord;
42
+ //# sourceMappingURL=wrapWord.js.map
package/package.json CHANGED
@@ -6,19 +6,17 @@
6
6
  },
7
7
  "dependencies": {
8
8
  "ajv": "^8.0.1",
9
- "lodash.clonedeep": "^4.5.0",
10
9
  "lodash.truncate": "^4.4.2",
11
10
  "slice-ansi": "^4.0.0",
12
- "string-width": "^4.2.0",
13
- "strip-ansi": "^6.0.0"
11
+ "string-width": "^4.2.3",
12
+ "strip-ansi": "^6.0.1"
14
13
  },
15
14
  "description": "Formats data into a string table.",
16
15
  "devDependencies": {
17
16
  "@types/chai": "^4.2.16",
18
- "@types/lodash.clonedeep": "^4.5.6",
19
17
  "@types/lodash.mapvalues": "^4.6.6",
20
18
  "@types/lodash.truncate": "^4.4.6",
21
- "@types/mocha": "^8.2.2",
19
+ "@types/mocha": "^9.0.0",
22
20
  "@types/node": "^14.14.37",
23
21
  "@types/sinon": "^10.0.0",
24
22
  "@types/slice-ansi": "^4.0.0",
@@ -27,19 +25,19 @@
27
25
  "chai": "^4.2.0",
28
26
  "chalk": "^4.1.0",
29
27
  "coveralls": "^3.1.0",
30
- "eslint": "^7.16.0",
28
+ "eslint": "^7.32.0",
31
29
  "eslint-config-canonical": "^25.0.0",
32
- "gitdown": "^3.1.3",
30
+ "gitdown": "^3.1.4",
33
31
  "husky": "^4.3.6",
34
- "js-beautify": "^1.13.0",
32
+ "js-beautify": "^1.14.0",
35
33
  "lodash.mapvalues": "^4.6.0",
36
34
  "mkdirp": "^1.0.4",
37
35
  "mocha": "^8.2.1",
38
36
  "nyc": "^15.1.0",
39
37
  "semantic-release": "^17.3.1",
40
- "sinon": "^9.2.2",
38
+ "sinon": "^12.0.1",
41
39
  "ts-node": "^9.1.1",
42
- "typescript": "4.2.4"
40
+ "typescript": "4.5.2"
43
41
  },
44
42
  "engines": {
45
43
  "node": ">=10.0.0"
@@ -58,37 +56,23 @@
58
56
  "ansi"
59
57
  ],
60
58
  "license": "BSD-3-Clause",
61
- "main": "./dist/index.js",
59
+ "main": "./dist/src/index.js",
62
60
  "files": [
63
- "dist/**/*.js",
64
- "dist/**/*.d.ts"
61
+ "dist/src/**/*.js",
62
+ "dist/src/**/*.d.ts"
65
63
  ],
66
64
  "name": "table",
67
- "nyc": {
68
- "extensions": [
69
- ".ts"
70
- ],
71
- "exclude": [
72
- "src/generated/validators.js",
73
- "test/**/*.ts"
74
- ],
75
- "reporter": [
76
- "text-lcov",
77
- "text"
78
- ]
79
- },
80
65
  "repository": {
81
66
  "type": "git",
82
67
  "url": "https://github.com/gajus/table"
83
68
  },
84
69
  "scripts": {
85
- "compile": "tsc",
86
- "prebuild": "rm -fr ./dist && mkdirp dist",
87
- "build": "npm run create-validators && npm run compile",
70
+ "prebuild": "rm -fr ./src/generated && mkdirp ./src/generated",
71
+ "build": "npm run create-validators && tsc",
88
72
  "create-readme": "gitdown ./.README/README.md --output-file ./README.md",
89
- "create-validators": "rm -fr ./src/generated && mkdirp ./src/generated && ajv compile --all-errors --inline-refs=false -s src/schemas/config -s src/schemas/streamConfig -r src/schemas/shared -c ajv-keywords/dist/keywords/typeof -o | js-beautify > ./src/generated/validators.js",
90
- "lint": "eslint --ignore-path .gitignore ./src ./test",
91
- "test": "npm run create-validators && mocha --require ts-node/register \"./test/**/*.ts\""
73
+ "create-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -s src/schemas/streamConfig -r src/schemas/shared -c ajv-keywords/dist/keywords/typeof -o | js-beautify > ./src/generated/validators.js",
74
+ "lint": "eslint ./src ./test",
75
+ "test": "nyc mocha && nyc check-coverage --lines 95"
92
76
  },
93
- "version": "6.7.1"
77
+ "version": "6.7.5"
94
78
  }
package/dist/table.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.table = void 0;
4
- const alignTableData_1 = require("./alignTableData");
5
- const calculateCellWidths_1 = require("./calculateCellWidths");
6
- const calculateRowHeights_1 = require("./calculateRowHeights");
7
- const drawTable_1 = require("./drawTable");
8
- const makeTableConfig_1 = require("./makeTableConfig");
9
- const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights");
10
- const padTableData_1 = require("./padTableData");
11
- const stringifyTableData_1 = require("./stringifyTableData");
12
- const truncateTableData_1 = require("./truncateTableData");
13
- const validateTableData_1 = require("./validateTableData");
14
- const table = (data, userConfig = {}) => {
15
- validateTableData_1.validateTableData(data);
16
- let rows = stringifyTableData_1.stringifyTableData(data);
17
- const config = makeTableConfig_1.makeTableConfig(rows, userConfig);
18
- rows = truncateTableData_1.truncateTableData(rows, config);
19
- const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config);
20
- rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config);
21
- rows = alignTableData_1.alignTableData(rows, config);
22
- rows = padTableData_1.padTableData(rows, config);
23
- const cellWidths = calculateCellWidths_1.calculateCellWidths(rows[0]);
24
- return drawTable_1.drawTable(rows, cellWidths, rowHeights, config);
25
- };
26
- exports.table = table;