https://github.com/imranbarbhuiya/ascii-pretty-table
A simple and lightweight library for creating pretty ASCII table.
https://github.com/imranbarbhuiya/ascii-pretty-table
Last synced: 4 months ago
JSON representation
A simple and lightweight library for creating pretty ASCII table.
- Host: GitHub
- URL: https://github.com/imranbarbhuiya/ascii-pretty-table
- Owner: imranbarbhuiya
- License: mit
- Created: 2021-12-15T11:06:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T07:33:44.000Z (about 3 years ago)
- Last Synced: 2025-01-15T16:17:16.097Z (6 months ago)
- Language: TypeScript
- Homepage: https://imranbarbhuiya.github.io/ascii-pretty-table/
- Size: 173 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README




# ascii-pretty-table
[ascii-pretty-table](https://www.npmjs.com/package/ascii-pretty-table), A simple and light weight library for creating ASCII tables.
[docs](https://www.imranbarbhuiya.github.io/ascii-pretty-table/)
## Uses
Install
```bash
npm install ascii-pretty-table
```Example
```js
const ascii = require("ascii-pretty-table"); //commonjs
import ascii from "ascii-pretty-table"; //es6const table = new ascii("A Title");
table.setHeading("Column 1", "Column 2");
table.addRow("Row 1", "Row 2");
table.addRow("Row 3", "Row 4");console.log(table.toString());
```Result
```js
+....................+
| A Title |
+''''''''''''''''''''+
| Column 1 | Column 2|
+''''''''''''''''''''+
| Row 1 | Row 2 |
+''''''''''''''''''''+
| Row 3 | Row 4 |
+''''''''''''''''''''+
```You can create table without headings as well.
You can export or import table as JSON.
```js
const ascii = require("ascii-pretty-table");
const table = new ascii("A Title");
table.addRow("Row 1", "Row 2");
table.addRow("Row 3", "Row 4");const json = table.toJSON();
const newTable = new ascii();
newTable.fromJSON(json);
```Change separators
```js
table.setSeparators({
top: ".",
bottom: "'",
edge: "|",
fill: "-",
corner: "+",
});
```## Methods and Properties
read docs for [ascii-pretty-table](https://imranbarbhuiya.github.io/ascii-pretty-table/)