console-table-printer
console-table-printer copied to clipboard
Bug: MaxLen minLen are working completely opposite as column options
import { Table } from 'console-table-printer';
const p = new Table({
columns: [
{ name: 'item', alignment: 'left' },
{
name: 'price',
alignment: 'right',
transform: (value) => `$${Number(value).toFixed(2)}`,
maxLen: 80,
},
],
});
p.addRows([
{ item: 'Coffee', price: 3.5 },
{ item: 'Sandwich', price: 7.99 },
{ item: 'Water', price: 1 },
]);
p.printTable();
┌──────────┬──────────────────────────────────────────┐
│ item │ price
├──────────┼──────────────────────────────────────────┤
│ Coffee │ $3.50 │
│ Sandwich │ $7.99 │
│ Water │ $1.00 │
└──────────┴──────────────────────────────────────────┘
if there is just maxLen then it goes to maxLen although smaller would look lot nicer
I wonder why do we need maxLen at all?
We need it only to force the len not to be more than that. And the only ways it can go over the length is if a sentence has very big word and we want to keep wrap the sentence to multiple lines.
So I think we need 2 things:
- Fix this Ticket as always keep size as min possible.
- If there is a maxLen then its used only to split particular words into multi line words