terminal-table-output
v1.4.0
Published
Build and output tables in the terminal or console as a string.
Downloads
61
Maintainers
Readme
terminal-table-output
Create and print tables in the terminal.
Installation
npm install terminal-table-output
Usage
Use this syntax
var tto = require('terminal-table-output').create();
tto.col('foo')
.col('bar')
.col('foobar')
.row()
.col('onoff')
.col('extraextra')
.line()
.col('line')
.col('special')
.line('(*)')
.print(true);
or this
tto.pushrow(['foo', 'bar', 'foobar'])
.pushrow(['onoff', 'extraextra'])
.line()
.pushrow(['line', 'special'])
.line("(*)")
.print(true);
both will output
foo | bar | foobar
onoff | extraextra |
===========================
line | special |
(*)(*)(*)(*)(*)(*)(*)(*)(*)
Functions
col(anyString)
col takes any string and pushes this into the last row.
row()
row creates a new row, using col after this will push into the new row
pushrow(arrayOfStrings)
creates a new row from the array of strings inserted into the function
line(anyString)
create a horizontal line in the table output, line takes a string argument as the char of string used in that specific line.
Settings
You can send in a settings object with the create function.
With these you can set the character that fills the text that has less width than the longest.
And you can set the delimiter between columns.
var tto = require('terminal-table-output')
.create({
fill: "-",
border: "/",
line: ">"
});
Would output the example above in the following way.
foo--/bar-------/foobar
onoff/extraextra/
>>>>>>>>>>>>>>>>>>>>>>>
table/delay-----/
Default settings
fill: " "
border: " | "
line: "="