peterroe / tablegger

Print table structure, support color characters

Home Page:https://tablegger.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tablegger

For printing tabular structured data, optional configuration and automatic alignment.

Feature

  • 📦 Out-of-the-box ANSI code support.
  • ⚙️ Supports flexible configurations such as borders and paddings.
  • 🔧 Automatic alignment.
  • 🤙🏻 Modify configuration anytime, anywhere.
  • 🦾 TypeScript, of course.

Try it now!

$ pnpm i tablegger

Usage

import { Tablegger } from 'tablegger'

const logger = new Tablegger({
  theme: 'table',
}).setRowHeaders(['Stage', 'Time', 'Rss', 'HeapTotal', 'HeapUsed'])

logger.addRow(['Init', '0ms', '38 MiB', '6.08 MiB', '5.12 MiB'])
logger.addRow(['Import', '4.7ms', '+9.63 MiB', '+4.77 MiB', '+4.77 MiB'])
logger.addRow(['Called', '7.24ms', '+0 Byte', '+0 Byte', '+792 Bytes'])

console.log('table theme:')
console.log(logger.toString())

// Change Config anywhere, anyTime
logger.setConfig({
  theme: 'horizontalLine',
})
console.log('horizontalLine theme:')
console.log(logger.toString())

logger.setConfig({
  theme: 'doubleLine',
})
console.log('doubleLine theme:')
console.log(logger.toString())

Read the documentation for more information

About

Print table structure, support color characters

https://tablegger.vercel.app

License:MIT License


Languages

Language:TypeScript 99.7%Language:Shell 0.3%