You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In node I can get the width of the console from process.stdout.columns. So I can get the available rest width for one column with the following formula:
const fixedColumnsWidth = [ w1, w2, ..., wn-1];
const fixedColumnsCount = fixedColumnsWidth.length; // n - 1
const consoleWidth = process.stdout.columns; // Other environments could not have process
// calculate width of column n
const wn = consoleWidth
- fixedColumnsWidth.reduce((sum, width) => sum + width, 0) // get the sum of all fixed column widths
- (fixedColumnsCount + 1) * 3 // add 1 for the variable width column, each column has three extra chars
- 1; // subtract one char for the first vertical line
I have only to make sure that wn does not get smaller than zero. So we should also define a minWidth for this column. I am using this on my tables with the help of a little manual calculation and a ternary expression.
The text was updated successfully, but these errors were encountered:
In node I can get the width of the console from process.stdout.columns. So I can get the available rest width for one column with the following formula:
I have only to make sure that
wn
does not get smaller than zero. So we should also define aminWidth
for this column. I am using this on my tables with the help of a little manual calculation and a ternary expression.The text was updated successfully, but these errors were encountered: