17 Star 23 Fork 7

小为 / word-table

加入 Gitee
与超过 1000 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

word-table

word-table is a simple javascript (browserjs / nodejs) library for drawing ascii tables in the terminal / console. Based on word-width.

Build Status Coverage Status npm npm npm

screenshot

1. Install & Import

npm install word-table

  • Import it with script tag in HTML.
<script type="text/javascript" src="dist/word-table.min.js"></script>
  • Import it with require.
var WordTable = require('word-table');
//or
import WordTable from 'word-table';

2. Usage & API

See a demo firstly:

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.

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, and run npm test can see the output.

The api are all chainable method, e.g.

var wt = new WordTable();
wt.reset()
  .setHeader(['id', 'name', 'birthday'])
  .appendBody(['#3', '佚名', '保密']);
var str = wt.string();

3. Test

npm install

npm run build

npm test

Or you can open the website, then test it in Console [F12].

4. LICENSE

MIT@hustcc.

简介

在控制台 / 终端 打印表格的 javascript 库,支持浏览器和nodejs环境。 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

word-table

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/hustcc/word-table.git
git@gitee.com:hustcc/word-table.git
hustcc
word-table
word-table
master

搜索帮助