terminal-table
Version:
View a table in the terminal.
70 lines (58 loc) • 1.47 kB
Markdown
terminal-table
==============
ターミナルにテーブルを表示するやつ

- ターミナルの幅に合わせて表示可能
- 中央寄せ, 右寄せ
- 日本語に対応 [eastasianwidth](https://github.com/komagata/eastasianwidth)
- 色付けが可能 [colors.js](https://github.com/marak/colors.js)
- 枠線は三種類から選べる、またカスタマイズも可能
```bash
$ npm i terminal-table
```
``` js
var Table = require("terminal-table");
var t = new Table();
t.push(
["First", "Second"],
["Foo", "Bar"]
);
console.log("" + t);
```
- borderStyle
- 1: ascii
- 2: unicode
- 3: unicode bold
- 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
``` js
new Table({
width: [10, "50%", "50%"]
});
```
- leftPadding, rightPadding
- push(["item", "item2",,,],,,)
- cell(row, column, text)
- attr(row, column, { attrs })
- attrRange({ range }, { attrs })
- removeCell(row, column)
- removeRow(row)
- removeColumn(column)