# nodejs-console-table

> This module is useful for creating tables with string data types from data objects-in-arrays javascript/nodejs in console or terminal

Latest version **1.0.5** (published 2022-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install nodejs-console-table
pnpm add nodejs-console-table
yarn add nodejs-console-table
bun add nodejs-console-table
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-10-11 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | 000int4120 |
| Keywords | nodejs, console, table, indonesia, bengkulu |

## Links

- npm: https://www.npmjs.com/package/nodejs-console-table
- Repository: https://github.com/kintaroazurachaniago/nodejs-console-table
- Homepage: https://github.com/kintaroazurachaniago/nodejs-console-table#readme
- Issues: https://github.com/kintaroazurachaniago/nodejs-console-table/issues
- npm.io page: https://npm.io/package/nodejs-console-table

## 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

- 1.0.5 (latest) — 2022-10-11
- 1.0.4 — 2022-10-11
- 1.0.3 — 2022-10-11
- 1.0.1 — 2022-10-11

## README

# nodejs-console-table
This module is useful for creating tables with string data types from data objects-in-arrays javascript/nodejs in console or terminal

# Installation

```
$ npm install nodejs-console-table
```

Or

```
$ git clone https://github.com/kintaroazurachaniago/nodejs-console-table.git
```

# Usage

For example, we have the following data:

```javascript
const data = [ /* array */
  /* object */
  { name : 'Naruto uzumaki', wife : 'Hinata hyuga', income : 100000 },
  { name : 'Sasuke uchiha', wife : 'Sakura haruno', income : 70000 },
  { name : 'Kakashi hatake', wife : null, income : 50000 },
  { name : 'Shikamaru nara', wife : 'Temari Kazekage', income : null }
]
```

We can turn the data above into a table in the following way

```javascript
const Table = require('nodejs-console-table')

Number.prototype.formatAngka = function (hasil = '') {
  this.toString().split('').reverse().forEach( (a, i) => hasil += i % 3 === 0 && i > 0 ? '.' + a : a )
  return hasil.split('').reverse().join('') + ',00'
}

const data = [ /* array */
  /* object */
  { name : 'Naruto uzumaki', wife : 'Hinata hyuga', income : 100000 },
  { name : 'Sasuke uchiha', wife : 'Sakura haruno', income : 70000 },
  { name : 'Kakashi hatake', wife : null, income : 50000 },
  { name : 'Shikamaru nara', wife : 'Temari Kazekage', income : null }
]

data.map( d => d.income = d.income ? d.income.formatAngka() : d.income )
const table = new Table(data, { right /* align */ : ['income'] }).table

console.log(table)
```

# Result

```
+----------------+-----------------+------------+
| Name           | Wife            |     Income |
+----------------+-----------------+------------+
| Naruto uzumaki | Hinata hyuga    | 100.000,00 |
| Sasuke uchiha  | Sakura haruno   |  70.000,00 |
| Kakashi hatake |        -        |  50.000,00 |
| Shikamaru nara | Temari Kazekage |     -      |
+----------------+-----------------+------------+
```

# Thank you for visiting :)

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