trainingproject
Version:
A module to teach you how to module.
70 lines (45 loc) • 1.52 kB
Markdown
[](https://nodei.co/npm/table-header/)
[](https://travis-ci.org/eush77/table-header) [![Dependency Status][david-badge]][david]
Add header to a text table, with border.
Text table is array of rows of equal length:
```js
var table = [
['red', '#ff0000'],
['green', '#00ff00'],
['blue', '#0000ff']
];
```
[]: https://david-dm.org/eush77/table-header
[]: https://david-dm.org/eush77/table-header.png
```js
var tableHeader = require('table-header');
tableHeader(table, ['color', 'code'])
//=> [
// ['color', 'code'],
// ['-----', '-------'],
// ['red', '#ff0000'],
// ['green', '#00ff00'],
// ['blue', '#0000ff']
// ]
```
Returns a new table with `header` and the same data.
Options:
- `border` — `false` for no border, `true` (default) for `-`-delimited border, single-character string for custom-delimited border.
- `stringLength` — string length function, e.g. to ignore escape codes.
Add header to existing `table`, modifying it.
- [text-table] module turns these tables to strings.
- [string-length] — string length function that ignores escape codes.
[]: http://npm.im/text-table
[]: http://npm.im/string-length
```
npm install table-header
```
MIT