console-table-printer 2.13.0 → 2.14.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.
package/README.md CHANGED
@@ -1,24 +1,12 @@
1
1
  <h1 align="center">console-table-printer</h1>
2
- <h3 align="center">🖥️🍭Printing Pretty Tables on your console</h3>
3
- <p align="center">
4
- <a href="https://codecov.io/gh/ayonious/console-table-printer">
5
- <img alt="codecov" src="https://codecov.io/gh/ayonious/console-table-printer/branch/master/graph/badge.svg">
6
- </a>
7
- <a href="https://badge.fury.io/js/console-table-printer">
8
- <img alt="npm version" src="https://badge.fury.io/js/console-table-printer.svg">
9
- </a>
10
- <a href="https://packagephobia.now.sh/result?p=console-table-printer">
11
- <img alt="install size" src="https://packagephobia.now.sh/badge?p=console-table-printer@latest">
12
- </a>
13
- </p>
14
- <p align="center">
15
- <a href="https://github.com/prettier/prettier">
16
- <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=plastic">
17
- </a>
18
- <a href="https://github.com/semantic-release/semantic-release">
19
- <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
20
- </a>
21
- </p>
2
+
3
+ > 🖥️🍭Printing Pretty Tables on your console</h3>
4
+
5
+ ![NPM Downloads](https://img.shields.io/npm/dw/console-table-printer)
6
+ [![install size](https://packagephobia.com/badge?p=console-table-printer)](https://packagephobia.com/result?p=console-table-printer)
7
+ [![npm version](https://badge.fury.io/js/console-table-printer.svg)](https://badge.fury.io/js/console-table-printer)
8
+ [![codecov](https://codecov.io/gh/console-table-printer/console-table-printer/graph/badge.svg?token=SWX9VBuYUs)](https://codecov.io/gh/console-table-printer/console-table-printer)
9
+
22
10
 
23
11
  ## Synopsis
24
12
 
@@ -45,7 +33,7 @@ const testCases = [
45
33
  printTable(testCases);
46
34
  ```
47
35
 
48
- ![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-quick-1.png)
36
+ ![Screenshot](https://cdn.jsdelivr.net/gh/console-table-printer/console-table-printer@master/static-resources/readme-quick-1.png)
49
37
 
50
38
  ## 🚨🚨Announcement🚨🚨 Official Documentation is moved [Here](https://console-table.netlify.app/docs)
51
39
 
@@ -70,7 +58,7 @@ p.addRows([
70
58
  p.printTable();
71
59
  ```
72
60
 
73
- ![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-instance-1.png)
61
+ ![Screenshot](https://cdn.jsdelivr.net/gh/console-table-printer/console-table-printer@master/static-resources/readme-instance-1.png)
74
62
 
75
63
  You can also put some color to your table like this:
76
64
 
@@ -82,7 +70,7 @@ p.addRow({ description: 'gelb bananen', value: 100 }, { color: 'yellow' });
82
70
  p.printTable();
83
71
  ```
84
72
 
85
- ![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-color-1.png)
73
+ ![Screenshot](https://cdn.jsdelivr.net/gh/console-table-printer/console-table-printer@master/static-resources/readme-color-1.png)
86
74
 
87
75
  You can also put properties based on columns (color/alignment/title)
88
76
 
@@ -112,7 +100,7 @@ p.addRow({ id: 3, text: 'rosa hemd wie immer', value: 100 }, { color: 'cyan' });
112
100
  p.printTable();
113
101
  ```
114
102
 
115
- ![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-columns-1.png)
103
+ ![Screenshot](https://cdn.jsdelivr.net/gh/console-table-printer/console-table-printer@master/static-resources/readme-columns-1.png)
116
104
 
117
105
  ## CLI
118
106
 
@@ -195,4 +183,4 @@ You can get color / alignment as types. Check Docs: [types-docs](https://console
195
183
 
196
184
  ## License
197
185
 
198
- [MIT](https://github.com/ayonious/console-table-printer/blob/master/LICENSE)
186
+ [MIT](https://github.com/console-table-printer/console-table-printer/blob/master/LICENSE)
@@ -1,4 +1,5 @@
1
+ import { ComplexOptions } from '../models/external-table';
1
2
  import TableInternal from './internal-table';
2
3
  export declare const renderTable: (table: TableInternal) => string;
3
- export declare const renderSimpleTable: (rows: any[]) => string;
4
- export declare const printSimpleTable: (rows: any[]) => void;
4
+ export declare const renderSimpleTable: (rows: any[], tableOptions?: ComplexOptions) => string;
5
+ export declare const printSimpleTable: (rows: any[], tableOptions?: ComplexOptions) => void;
@@ -114,13 +114,13 @@ const renderTable = (table) => {
114
114
  return ret.join('\n');
115
115
  };
116
116
  exports.renderTable = renderTable;
117
- const renderSimpleTable = (rows) => {
118
- const table = new internal_table_1.default();
117
+ const renderSimpleTable = (rows, tableOptions) => {
118
+ const table = new internal_table_1.default(tableOptions);
119
119
  table.addRows(rows);
120
120
  return (0, exports.renderTable)(table);
121
121
  };
122
122
  exports.renderSimpleTable = renderSimpleTable;
123
- const printSimpleTable = (rows) => {
124
- console.log((0, exports.renderSimpleTable)(rows));
123
+ const printSimpleTable = (rows, tableOptions) => {
124
+ console.log((0, exports.renderSimpleTable)(rows, tableOptions));
125
125
  };
126
126
  exports.printSimpleTable = printSimpleTable;
@@ -5,9 +5,14 @@ const table_helpers_1 = require("../utils/table-helpers");
5
5
  const createComputedColumnsIfNecessary = (table) => {
6
6
  if (table.computedColumns.length) {
7
7
  table.computedColumns.forEach((computedColumn) => {
8
+ // This can happen if renderTable/printTable is called multiple times
9
+ const isColumnAlreadyExists = table.columns.some((col) => col.name === computedColumn.name);
10
+ if (isColumnAlreadyExists) {
11
+ return;
12
+ }
8
13
  table.addColumn(computedColumn);
9
- table.rows.forEach((row, index, array) => {
10
- const arrayRowText = array.map(() => row.text);
14
+ table.rows.forEach((row, index, rowsArray) => {
15
+ const arrayRowText = rowsArray.map((elemInRowsArray) => elemInRowsArray.text);
11
16
  row.text[computedColumn.name] = computedColumn.function(row.text, index, arrayRowText);
12
17
  });
13
18
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "console-table-printer",
3
- "version": "2.13.0",
4
- "repository": "github:ayonious/console-table-printer",
3
+ "version": "2.14.0",
4
+ "repository": "github:console-table-printer/console-table-printer",
5
5
  "description": "Printing pretty tables on console log",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "jest": "^29.7.0",
40
40
  "prettier": "^3.5.3",
41
41
  "pretty-quick": "^4.1.1",
42
- "semantic-release": "^24.2.4",
42
+ "semantic-release": "^24.2.5",
43
43
  "ts-jest": "^29.3.4",
44
44
  "typescript": "^5.8.3"
45
45
  },