terminal-table

View a table in the terminal.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
terminal-table
1930.0.129 years ago9 years agoMinified + gzip package size for terminal-table in KB

Readme

terminal-table
View a table in the terminal
screenshot

Features

  • To fit the width of the terminal can be displayed
  • Centered, right-justified
  • Corresponding to the full-width eastasianwidth
  • Coloring is possible colors.js
  • Border can choose from three styles and user custom style.

Installation

$ npm i terminal-table

Usage

var Table = require("terminal-table");
var t = new Table();

t.push(
  ["First", "Second"],
  ["Foo", "Bar"]
);

console.log("" + t);

API

Constructor options

  • borderStyle
- 1: ascii
screenshot - 2: unicode
screenshot - 3: unicode bold
screenshot - 0: user custom ``` js
var t = new Table({
  borderStyle: 0,
  border: {
    sep: "║",
    topLeft: "╔", topMid: "╦", top: "═", topRight: "╗",
    midLeft: "╠", midMid: "╬", mid: "═", midRight: "╣",
    botLeft: "╚", botMid: "╩", bot: "═", botRight: "╝"
  }
});
```
  • horizontalLine - Boolean
  • width - Array
new Table({
  width: [10, "50%", "50%"]
});
  • leftPadding, rightPadding

Methods

- attrs - align: left, center, right - color: from colors.js, e.g. blue, red... - bg: blue, black...
  • attrRange({ range }, { attrs })
- range - row: start, end - column: start, end
  • removeCell(row, column)
  • removeRow(row)
  • removeColumn(column)