@kazesolo/console-table
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

console-table

npm version install size

Installation

npm install @kazesolo/console-table

OR

yarn add @kazesolo/console-table

Basic Example

const { printTable } = require('@kazesolo/console-table');//Function 

// Table
const table = [
  { index: 1, Name : 'Kaze', High : 157 }
];

//print
printTable(table);

Screenshot

Another

const { Table } = require('@kazesolo/console-table');

//Create a table
const p = new Table();

//add rows with color
p.addRow({ index: 1, text: 'red wine please', value: 10.212 });
p.addRow({ index: 2, text: 'green gemuse please', value: 20.0 });
p.addRows([
  //adding multiple rows are possible
  { index: 3, text: 'gelb bananen bitte', value: 100 },
  { index: 4, text: 'update is working', value: 300 },
]);

//print
p.printTable();

Screenshot

Table Berwarna

const p = new Table();
p.addRow({ index: 1, text: 'red', value: 100 }, { color: 'red' });
p.addRow({ index: 2, text: 'green', value: 100 }, { color: 'green' });
p.addRow({ index: 3, text: 'yellow', value: 100 }, { color: 'yellow' });
p.addRow({ index: 4, text: 'blue', value: 100 }, { color: 'blue' });
p.addRow({ index: 5, text: 'magenta', value: 100 }, { color: 'magenta' });
p.addRow({ index: 6, text: 'cyan', value: 100 }, { color: 'cyan' });
p.addRow({ index: 7, text: 'white', value: 100 }, { color: 'white' });
p.addRow({ index: 8, text: 'crimson', value: 100 }, { color: 'crimson' });
p.addRow({ index: 9, text: 'white_bold', value: 100 }, { color: 'white_bold' });
p.addRow({ index: 10, text: 'reset', value: 100 }, { color: 'reset' });


p.printTable();

Screenshot

Table color/alignment/title

const p = new Table({
columns: [
    { name: 'index', alignment: 'left', color: 'blue' }, 
    { name: 'text', alignment: 'right' },
    { name: 'is_priority_today', title: 'Is This Priority?' }, 
  ]
    
});

p.addRow({ index: 1, text: 'red', value: 100 }, { color: 'red' });
p.addRow(
  { index: 2, text: 'green', value: 20.0 },
  { color: 'green' } 
);
p.addRow(
  { index: 3, text: 'yellow', value: 100, is_priority_today: 'Y' },
  { color: 'yellow' }
);
p.addRow(
  { index: 4, text: 'cyan', value: 100, is_priority_today: 'N' },
  { color: 'cyan' }
);
p.printTable();

Screenshot

Thanks to

Matt Travi James Henry chalk

Package Sidebar

Install

npm i @kazesolo/console-table

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

40.8 kB

Total Files

31

Last publish

Collaborators

  • kazedevid