Gathering detailed insights and metrics for @alexbosworth/cli-table3
Gathering detailed insights and metrics for @alexbosworth/cli-table3
Gathering detailed insights and metrics for @alexbosworth/cli-table3
Gathering detailed insights and metrics for @alexbosworth/cli-table3
npm install @alexbosworth/cli-table3
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
541 Stars
416 Commits
45 Forks
3 Watching
9 Branches
21 Contributors
Updated on 22 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-19.7%
147
Compared to previous day
Last week
-14%
924
Compared to previous week
Last month
-9.1%
4,549
Compared to previous month
Last year
20.5%
40,224
Compared to previous year
2
8
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.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
32 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More