tekstable

1.0.1 • Public • Published

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 |
+---+-------+-----------+----+

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.11latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.11
1.0.00

Package Sidebar

Install

npm i tekstable

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

6.63 kB

Total Files

5

Last publish

Collaborators

  • dkrypt