columnify
columnify copied to clipboard
Separate Header with a -------
Would love an option to separate the column headers from the body of the table with a line.
I love the truncation and autowrap features of your module. But, for some of my tables having a table separator looks a lot cleaner in my opinion.
Using tablify:
Using columnify
+1
+1. I added the following line to add '----' after header.
col = col.slice(0, col.indexOf('\n')) + '\n' +'-'.repeat(col.indexOf('\n')) + col.slice(col.indexOf('\n'));
I did it by doing a simple function that adds the dashes
const addDashes = (text: string) => {
const repeat = () => `${'-'.repeat(30)}`;
return `${repeat()}\n${text}\n${repeat()}`
}
and then calling the function in my config.headingTransform
.
Like this:
columnify(data,{headingTransform: text => addDashes(text)})
Home someone can use this snippet