Gathering detailed insights and metrics for @wekanteam/cli-table3
Gathering detailed insights and metrics for @wekanteam/cli-table3
Gathering detailed insights and metrics for @wekanteam/cli-table3
Gathering detailed insights and metrics for @wekanteam/cli-table3
npm install @wekanteam/cli-table3
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
428 Commits
1 Watching
1 Branches
1 Contributors
Updated on 10 Jan 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
205%
122
Compared to previous day
Last week
117.7%
442
Compared to previous week
Last month
34.2%
984
Compared to previous month
Last year
-50.6%
5,314
Compared to previous year
1
This utility allows you to render unicode-aided tables on the command line from your node.js scripts.
cli-table3
is based on (and api compatible with) the original cli-table,
and cli-table2, which are both
unmaintained. cli-table3
includes all the additional features from
cli-table2
.
1npm install cli-table3
A portion of the unit test suite is used to generate examples:
This package is api compatible with the original cli-table. So all the original documentation still applies (copied below).
1var Table = require('cli-table3'); 2 3// instantiate 4var table = new Table({ 5 head: ['TH 1 label', 'TH 2 label'] 6 , colWidths: [100, 200] 7}); 8 9// table is an Array, so you can `push`, `unshift`, `splice` and friends 10table.push( 11 ['First value', 'Second value'] 12 , ['First value', 'Second value'] 13); 14 15console.log(table.toString());
1var Table = require('cli-table3'); 2var table = new Table(); 3 4table.push( 5 { 'Some key': 'Some value' } 6 , { 'Another key': 'Another value' } 7); 8 9console.log(table.toString());
Cross tables are very similar to vertical tables, with two key differences:
head
setting when instantiated that has an empty string as the first header1var Table = require('cli-table3'); 2var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] }); 3 4table.push( 5 { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] } 6 , { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] } 7); 8 9console.log(table.toString());
The chars
property controls how the table is drawn:
1var table = new Table({ 2 chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗' 3 , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝' 4 , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼' 5 , 'right': '║' , 'right-mid': '╢' , 'middle': '│' } 6}); 7 8table.push( 9 ['foo', 'bar', 'baz'] 10 , ['frob', 'bar', 'quuz'] 11); 12 13console.log(table.toString()); 14// Outputs: 15// 16//╔══════╤═════╤══════╗ 17//║ foo │ bar │ baz ║ 18//╟──────┼─────┼──────╢ 19//║ frob │ bar │ quuz ║ 20//╚══════╧═════╧══════╝
Empty decoration lines will be skipped, to avoid vertical separator rows just set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string:
1var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} }); 2table.push( 3 ['foo', 'bar', 'baz'] 4 , ['frobnicate', 'bar', 'quuz'] 5); 6 7console.log(table.toString()); 8// Outputs: (note the lack of the horizontal line between rows) 9//┌────────────┬─────┬──────┐ 10//│ foo │ bar │ baz │ 11//│ frobnicate │ bar │ quuz │ 12//└────────────┴─────┴──────┘
By setting all chars to empty with the exception of 'middle' being set to a single space and by setting padding to zero, it's possible to get the most compact layout with no decorations:
1var table = new Table({ 2 chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' 3 , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' 4 , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' 5 , 'right': '' , 'right-mid': '' , 'middle': ' ' }, 6 style: { 'padding-left': 0, 'padding-right': 0 } 7}); 8 9table.push( 10 ['foo', 'bar', 'baz'] 11 , ['frobnicate', 'bar', 'quuz'] 12); 13 14console.log(table.toString()); 15// Outputs: 16//foo bar baz 17//frobnicate bar quuz
Later versions of cli-table3 supporting debugging your table data.
Enable and use debugging:
var table = new Table({ debug: 1 });
table.push([{}, {},}); // etc.
console.log(table.toString());
table.messages.forEach((message) => console.log(message));
If you are rendering multiple tables with debugging on run Table.reset()
after
rendering each table.
Clone the repository and run yarn install
to install all its submodules, then run one of the following commands:
1$ yarn test:coverage
1$ yarn test:watch
1$ yarn docs
(The MIT License)
Copyright (c) 2014 James Talmage <james.talmage@jrtechnical.com>
Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <dev@learnboost.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.