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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bobanm/table-printer

v0.1.0

Published

A simple, ultra lightweight class for printing beautiful minimalistic CLI tables.

Readme

CLI Table Printer

A simple, ultra lightweight class for printing beautiful minimalistic CLI tables.

#   TIME       SIDE   OUTCOME   SHARES   PRICE   COST $   TOT SHRS
------------------------------------------------------------------
1   21:45:18   BUY    Down       20.00   41.00     8.20      20.00
2   21:45:18   BUY    Down        5.00   41.00     2.05      25.00
3   21:45:20   BUY    Down        5.00   41.00     2.05      30.00
4   21:45:20   BUY    Down       11.98   38.00     4.55      41.98
------------------------------------------------------------------
5   21:45:20   BUY    Up          5.00   60.00     3.00       5.00
6   21:45:20   BUY    Up         20.00   60.00    12.00      25.00
7   21:45:20   BUY    Up         12.24   59.00     7.22      37.24

Why publishing it?

I noticed that pretty much every CLI project of mine had a need to format and print nice tables. So it made sense to avoid code duplication and move it to an external package. I wanted something that is simple, lightweight and easy to use. I figured out the other devs might find it useful, too.

How to use it?

Add the package to your project:

bun add @bobanm/table-printer

Then import it in the file which formats/prints a table:

import { TablePrinter } from '@bobanm/table-printer'

Create a new table and provide headers in the constructor.

const tradesTable = new TablePrinter([
    ['#', 'TIME', 'SIDE', 'OUTCOME', 'SHARES', 'PRICE', 'COST $', 'TOT SHRS'],
])

By default, your table will

  1. use spacing of 3 characters between columns
  2. separate header from the body using a line
  3. not print a line after the last row
  4. align all columns to the left
  5. not group rows by the value of a certain column

You can override those default values in the constructor:

const tradesTable = new TablePrinter(
    [
        ['#', 'TIME', 'SIDE', 'OUTCOME', 'SHARES', 'PRICE', 'COST $', 'TOT SHRS'],
    ],
    4,
    false,
    true,
    [0, 4, 5, 6, 7],
    3,
)

Those are all public properties, so you can also change them at any time using:

tradesTable.spacing = 4
tradesTable.hasHeader = false
tradesTable.hasBottomLine = true
tradesTable.rightAlignedColumns = [0, 4, 5, 6, 7]
tradesTable.groupByColumn = 3

If the contents of the table are provided in advance, you can also add them as additional arrays in the constructor. Otherwise, you can add them later using addRow() method:

for (const position of account.assetPositions) {
    tradesTable.addRow([
        index + 1,
        convertToEtTimezone(trade.timestamp),
        trade.side,
        trade.outcome,
        trade.size.toFixed(2),
        (trade.price * 100).toFixed(2),
        (trade.size * trade.price).toFixed(2),
        totalShares[outcome].toFixed(2),
    ])
}

Finally, to format the table to a string and print it in the console, use toString() method:

console.log(tradesTable.toString())