# word-table
**Repository Path**: fnet/word-table
## Basic Information
- **Project Name**: word-table
- **Description**: 在控制台 / 终端 打印表格的 javascript 库,支持浏览器和nodejs环境。
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: http://git.hust.cc/word-table/
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 7
- **Created**: 2016-10-20
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# word-table
> **word-table** is a simple javascript (browserjs / nodejs) library for drawing ascii tables in the `terminal` / `console`. Based on [word-width](https://github.com/hustcc/word-width).
[](https://travis-ci.org/hustcc/word-table) [](https://www.npmjs.com/package/word-table) [](https://www.npmjs.com/package/word-table) [](https://www.npmjs.com/package/word-table)

# 1. Install & Import
> **npm install word-table**
- Import it with `script` tag in HTML.
```js
```
- Import it with `require`.
```js
var WorkTable = require('word-table');
//or
import WorkTable from 'word-table';
```
# 2. Usage & API
See a demo firstly:
```js
var header = ['id', 'name', 'birthday'];
var body = [
['#1', '王小为', '1992-08-01', '备注:hustcc'],
['#2', '小泥巴', '1992-09-20'],
['#3', '佚名', '保密']
];
// basic usage
var wt = new WordTable(header, body);
console.log(wt.string());
```
The API is so simple that documents are not needed.
```js
wt.setHeader(['id', 'name', 'birthday']);
wt.appendBody(['#3', '佚名', '保密']);
wt.setBody([['#4', '在线工具', '保密', 'atool.org']]);
wt.array();
wt.string();
wt.reset();
```
Detail usage and demo code, can see [here](tests/test.js), and run `npm test` can see the output.
# 3. Test
> npm install
>
> npm test
Or you can open the [website](http://git.hust.cc/word-table/), then test it in `Console [F12]`.
# 4. LICENSE
MIT