Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 4 hours 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 (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T07:33:44.000Z (over 2 years ago)
- Last Synced: 2024-05-02T22:12:06.378Z (7 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
![npm](https://img.shields.io/npm/v/ascii-pretty-table?style=for-the-badge)
![npm](https://img.shields.io/npm/dw/ascii-pretty-table?style=for-the-badge)
![GitHub](https://img.shields.io/github/license/imranbarbhuiya/ascii-pretty-table?style=for-the-badge)
![Build Status](https://img.shields.io/github/workflow/status/imranbarbhuiya/ascii-pretty-table/Build/main?label=Build&style=for-the-badge&logo=TypeScript)
![Test Status](https://img.shields.io/github/workflow/status/imranbarbhuiya/ascii-pretty-table/Test/main?label=Test&style=for-the-badge&logo=Jest)# 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/)