Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tty-table

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tty-table

Command line table generator.

  • 2.6.12
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is tty-table?

The tty-table npm package is used to create and display tables in the terminal. It provides a simple and flexible way to format and present tabular data in a visually appealing manner.

What are tty-table's main functionalities?

Basic Table Creation

This feature allows you to create a basic table with specified headers and rows. The table is then rendered and displayed in the terminal.

const ttyTable = require('tty-table');
const header = [
  { value: 'Name', width: 30, headerColor: 'cyan' },
  { value: 'Age', width: 10, headerColor: 'cyan' }
];
const rows = [
  ['Alice', 30],
  ['Bob', 25]
];
const table = ttyTable(header, rows);
console.log(table.render());

Customizing Table Appearance

This feature allows you to customize the appearance of the table, including border style, border color, padding, alignment, and text color.

const ttyTable = require('tty-table');
const header = [
  { value: 'Name', width: 30, headerColor: 'cyan', color: 'white', align: 'left' },
  { value: 'Age', width: 10, headerColor: 'cyan', color: 'white', align: 'right' }
];
const rows = [
  ['Alice', 30],
  ['Bob', 25]
];
const options = {
  borderStyle: 'solid',
  borderColor: 'blue',
  paddingBottom: 0,
  headerAlign: 'center',
  align: 'center',
  color: 'white'
};
const table = ttyTable(header, rows, options);
console.log(table.render());

Adding Footers

This feature allows you to add footers to the table, which can be used to display summary information or totals.

const ttyTable = require('tty-table');
const header = [
  { value: 'Name', width: 30, headerColor: 'cyan' },
  { value: 'Age', width: 10, headerColor: 'cyan' }
];
const rows = [
  ['Alice', 30],
  ['Bob', 25]
];
const footer = [
  { value: 'Total', colspan: 1, align: 'right' },
  { value: '2', align: 'right' }
];
const table = ttyTable(header, rows, { footer });
console.log(table.render());

Other packages similar to tty-table

Keywords

FAQs

Package last updated on 21 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc