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

ascii-table

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ascii-table

Easy tables for your console data

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ascii-table?

The ascii-table npm package is a simple and lightweight library for creating and formatting ASCII tables in Node.js. It allows you to easily generate tables with headers, rows, and columns, and provides various customization options for table appearance.

What are ascii-table's main functionalities?

Creating a Basic Table

This feature allows you to create a basic ASCII table with a title, headers, and rows. The code sample demonstrates how to set up a table with a title 'Sample Table', add headers 'Name', 'Age', and 'City', and add two rows of data.

const AsciiTable = require('ascii-table');
let table = new AsciiTable('Sample Table');
table.setHeading('Name', 'Age', 'City');
table.addRow('Alice', 25, 'New York');
table.addRow('Bob', 30, 'Los Angeles');
console.log(table.toString());

Customizing Table Appearance

This feature allows you to customize the appearance of the table, such as aligning the text in different columns. The code sample shows how to align the first column to the left, the second column to the center, and the third column to the right.

const AsciiTable = require('ascii-table');
let table = new AsciiTable('Styled Table');
table.setHeading('Name', 'Age', 'City');
table.addRow('Alice', 25, 'New York');
table.addRow('Bob', 30, 'Los Angeles');
table.setAlign(0, AsciiTable.LEFT);
table.setAlign(1, AsciiTable.CENTER);
table.setAlign(2, AsciiTable.RIGHT);
console.log(table.toString());

Adding Rows Dynamically

This feature allows you to add rows to the table dynamically, which is useful when dealing with data from external sources. The code sample demonstrates how to add multiple rows from an array of data.

const AsciiTable = require('ascii-table');
let table = new AsciiTable('Dynamic Rows');
table.setHeading('Name', 'Age', 'City');
const data = [
  ['Alice', 25, 'New York'],
  ['Bob', 30, 'Los Angeles'],
  ['Charlie', 35, 'Chicago']
];
data.forEach(row => table.addRow(...row));
console.log(table.toString());

Other packages similar to ascii-table

Keywords

FAQs

Package last updated on 11 Apr 2016

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