Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bernardini687/minitable

🦕 deno utility module for simple table printing
https://github.com/bernardini687/minitable

deno minimal module

Last synced: 3 days ago
JSON representation

🦕 deno utility module for simple table printing

Awesome Lists containing this project

README

        

# minitable

_shape a list of data into a table_

simple helper to get a string designed to be printed as a table.

# usage

```ts
import { table } from 'https://deno.land/x/[email protected]/mod.ts'

const fruits = [
{ name: 'mango', color: 'orange', quantity: 3 },
{ name: 'lemon', color: 'yellow', quantity: 1 },
{ name: 'strawberry', color: '', quantity: 5 },
{ name: 'tomato', color: 'red', quantity: 17 },
]

// change the order of the columns
const t = table(fruits, ['quantity', 'color', 'name'])

console.log(t)
/*
quantity color name
3 orange mango
1 yellow lemon
5 strawberry
17 red tomato
*/
```

# options

```ts
// pick the properties to show
const t = table(fruits, ['color', 'name'], {
padding: 4,
upcaseHeader: true,
emptyReplacer: 'NO DATA POINT',
})

console.log(t)
/*
COLOR NAME
orange mango
yellow lemon
NO DATA POINT strawberry
red tomato
*/
```