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

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

easy-table

Nice text table for the CLI

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is easy-table?

The easy-table npm package is a simple and flexible library for creating and formatting text tables in Node.js. It allows you to easily create tables, format columns, and perform various operations on table data.

What are easy-table's main functionalities?

Creating a Simple Table

This feature allows you to create a simple table from an array of objects. Each object represents a row in the table, and the properties of the objects are the columns.

const Table = require('easy-table');

let data = [
  { name: 'John', age: 25, city: 'New York' },
  { name: 'Jane', age: 30, city: 'San Francisco' },
  { name: 'Mike', age: 27, city: 'Chicago' }
];

let t = new Table;
data.forEach(function(person) {
  t.cell('Name', person.name);
  t.cell('Age', person.age);
  t.cell('City', person.city);
  t.newRow();
});

console.log(t.toString());

Formatting Columns

This feature allows you to format columns in the table. In this example, the 'Age' column is formatted as a number with no decimal places.

const Table = require('easy-table');

let data = [
  { name: 'John', age: 25, city: 'New York' },
  { name: 'Jane', age: 30, city: 'San Francisco' },
  { name: 'Mike', age: 27, city: 'Chicago' }
];

let t = new Table;
data.forEach(function(person) {
  t.cell('Name', person.name);
  t.cell('Age', person.age, Table.number(0));
  t.cell('City', person.city);
  t.newRow();
});

console.log(t.toString());

Sorting Rows

This feature allows you to sort the rows in the table. In this example, the rows are sorted by the 'Age' column in descending order.

const Table = require('easy-table');

let data = [
  { name: 'John', age: 25, city: 'New York' },
  { name: 'Jane', age: 30, city: 'San Francisco' },
  { name: 'Mike', age: 27, city: 'Chicago' }
];

let t = new Table;
data.forEach(function(person) {
  t.cell('Name', person.name);
  t.cell('Age', person.age);
  t.cell('City', person.city);
  t.newRow();
});

t.sort(['Age|des']);

console.log(t.toString());

Other packages similar to easy-table

Keywords

FAQs

Package last updated on 08 Jan 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