1.4.0 • Published 2 years ago

terminal-table-output v1.4.0

Weekly downloads
209
License
ISC
Repository
github
Last release
2 years ago

terminal-table-output

Create and print tables in the terminal.

NPM

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: "="

1.4.0

2 years ago

1.3.2

7 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago