@kazesolo/console-table
v1.0.0
Published
console table membantu anda mempercantik script mu!
Downloads
16
Readme
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);
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();
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();
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();