# table-header

> Add header to a text table

Latest version **0.2.2** (published 2015-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install table-header
pnpm add table-header
yarn add table-header
bun add table-header
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2015-06-05 |
| First published | 2015-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eugene Sharygin |
| Maintainers | eush77 |
| Keywords | table, header, text-table, border |

## Links

- npm: https://www.npmjs.com/package/table-header
- Repository: https://github.com/eush77/table-header
- Issues: https://github.com/eush77/table-header/issues
- npm.io page: https://npm.io/package/table-header

## Dependencies (1)

- [repeat-string](https://npm.io/package/repeat-string.md) ^1.5.2

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2015-06-05
- 0.2.1 — 2015-05-30
- 0.2.0 — 2015-05-30
- 0.1.0 — 2015-05-30

## README

[![npm](https://nodei.co/npm/table-header.png)](https://nodei.co/npm/table-header/)

# table-header

[![Build Status](https://travis-ci.org/eush77/table-header.svg?branch=master)](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']
];
```

[david]: https://david-dm.org/eush77/table-header
[david-badge]: https://david-dm.org/eush77/table-header.png

## Example

```js
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.

[text-table]: http://npm.im/text-table
[string-length]: http://npm.im/string-length

## Install

```
npm install table-header
```

## License

MIT

---
_Source: https://npm.io/package/table-header · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
