beauty-table
v0.1.0
Published
Enhanced Unicode tables for the command line, inspired by the original cli-table, offering visually appealing and customizable table formatting.
Downloads
6
Maintainers
Readme
beauty-table
This utility allows you to render unicode-aided tables on the command line from your node.js scripts.
beauty-table
is based on (and api compatible with) the original cli-table, cli-table2, and
cli-table3.
Features
- Typescript
- Ability to use hex and rgb for colors.
Installation
npm install beauty-table
How to use
A portion of the unit test suite is used to generate examples:
- basic-usage - covers basic uses.
- advanced - covers using the new column and row span features.
This package is api compatible with the original cli-table and cli-table3. So all the original documentation still applies (copied below).
Horizontal Tables
import Table from 'beauty-table';
// instantiate
const table = new Table({
head: ['TH 1 label', 'TH 2 label']
, colWidths: [100, 200]
});
// table is an Array, so you can `push`, `unshift`, `splice` and friends
table.push(
['First value', 'Second value']
, ['First value', 'Second value']
);
console.log(table.toString());
Vertical Tables
import Table from 'beauty-table';
const table = new Table();
table.push(
{ 'Some key': 'Some value' }
, { 'Another key': 'Another value' }
);
console.log(table.toString());
Credits
- 0xJWLabs - author <[email protected]> (0xJWLabs)
- James Talmage - author of cli-table3 <[email protected]> (jamestalmage)
- Guillermo Rauch - author of the original cli-table <[email protected]> (Rauchg)
License
(The MIT License)
Copyright (c) 2024 0xJWLabs <[email protected]>
cli-table3 code/documentation: Copyright (c) 2014 James Talmage <[email protected]>
Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <[email protected]>
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.