npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

live-text-table

v1.0.0

Published

like text-table, but printing live

Downloads

6

Readme

live-text-table

travis cov-coveralls npm-downloads npm-version dm-david

Yet another library for printing tables to the terminal. In this case though, there is no expectation that you will have all the data ahead of time. Instead, you can set up your column definitions ahead of time, and data will be printed to the terminal as it is provided, allowing to provide feedback immediately as you fetch more and more data.

If you do have all you data already, consider using fancy-text-table, which will be able to automatically size the columns for you.

require('live-text-table')({Object} options) → Table

Initializes a new table. All options are optional, with the defaults resulting in printing directory to console similar to console.log(param1, param2, param3, ...). The following options are available:

  • columns {Array[{Object}]}: definitions for each column, in order. Each column has the following properties:
    • size {Integer}: the number of characters in each cell
    • align {String}: how to align the colums, either left, right, or center
    • char {String}: the character to use when padding the string for alignment
  • separator {String}: the text to use to separate columns
const table = require('live-text-table')({
  columns: [
    { size: 2, align: 'left' },
    { size: 45, align: 'left', char: chalk.gray('.') },
    { size: 10, align: 'right' }
  ],
  separator: ' | '
});

Each instance of a table has the following methods:

Table.title({String} title)

Creates a title. This string will span across cells of a table, and not factor in cell alignment.

table.title('This Is My Table');

Table.row(...args)

Creates a row of items as defined in the table options. Note that if a value is larger than the defined size, it will push the rest of the content and misalign that row in the table.

table.row('1', 'value 1', 1234);
table.row('2', 'value 2', 5678);
table.row('3', 'value 3', 90);

Table.line()

Creates an empty line in teh table. This is useful if you want to break up chunkcs of cells.

table.line();

Example

Full table example. Feel free to use colors anywhere you'd like to make your tables even prettier!

const chalk = require('chalk');
const table = require('live-text-table')({
  columns: [
    { size: 2, align: 'left' },
    { size: 15, align: 'left', char: chalk.gray('.') },
    { size: 6, align: 'right' }
  ],
  separator: ' | '
});

table.title('My Fruits');
table.line();
table.row(chalk.dim('#1'), chalk.cyan('pineapples'), 1234);
table.row(chalk.dim('#2'), chalk.cyan('oranges'), 5678);
table.row(chalk.dim('#3'), chalk.cyan('bananas'), 90);

// My Fruits
//
// #1 | pineapples..... |   1234
// #2 | oranges........ |   5678
// #3 | bananas........ |     90