Skip to content

dkrypt/tekstable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TeksTable

Generate bordered table with data, suitable for printing to console.

Quickstart

Example with default values

const tekstable = require('tekstable');
const tableData = [
    ["No.", "Name", "Address", "Age"],
    ["1", "Alice", "Michigan", "22"],
    ["2", "Bob", "Bengaluru", "23"]
]

console.log(tekstable(tableData));

Output:

+-------+---------+-------------+-------+
|  No.  |  Name   |  Address    |  Age  |
+-------+---------+-------------+-------+
|  1    |  Alice  |  Michigan   |  22   |
|  2    |  Bob    |  Bengaluru  |  23   |
+-------+---------+-------------+-------+

Example with custom options

const tekstable = require('tekstable');
const tableData = [
    ["No.", "Name", "Address", "Age"],
    ["1", "Alice", "Michigan", "22"],
    ["2", "Bob", "Bengaluru", "23"]
]

console.log(tekstable(tableData, { spacing: 3, isHeader: true}));

Output:

+---------+-----------+---------------+---------+
|   No.   |   Name    |   Address     |   Age   |
+---------+-----------+---------------+---------+
|   1     |   Alice   |   Michigan    |   22    |
|   2     |   Bob     |   Bengaluru   |   23    |
+---------+-----------+---------------+---------+

Example without header

const tekstable = require('tekstable');
const tableData = [
    ["1", "Alice", "Michigan", "22"],
    ["2", "Bob", "Bengaluru", "23"]
];

console.log(tekstable(tableData, { spacing: 1, isHeader: false}));

Output:

+---+-------+-----------+----+
| 1 | Alice | Michigan  | 22 |
| 2 | Bob   | Bengaluru | 23 |
+---+-------+-----------+----+

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published