0.2.2 • Published 9 years ago
table-header v0.2.2
table-header
Add header to a text table, with border.
Text table is array of rows of equal length:
var table = [
['red', '#ff0000'],
['green', '#00ff00'],
['blue', '#0000ff']
];
Example
var tableHeader = require('table-header');
tableHeader(table, ['color', 'code'])
//=> [
// ['color', 'code'],
// ['-----', '-------'],
// ['red', '#ff0000'],
// ['green', '#00ff00'],
// ['blue', '#0000ff']
// ]
API
tableHeader(table, header, [opts])
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.
tableHeader.add(table, header, [opts])
Add header to existing table
, modifying it.
Related
- text-table module turns these tables to strings.
- string-length — string length function that ignores escape codes.
Install
npm install table-header
License
MIT