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

tablur

v1.2.1

Published

Easily create tables for your cli.

Downloads

24

Readme

Tablur pronounced "tay-bler" is a simple cli table util. It is similar to cliui with a few extra helpers. The main advantage to Tablur is that it's quick and it's written in Typescript. Typings for existing table utils isn't that great and in part the reason for this release.

Install

$ npm install tablur

Usage

Tablur is similar to other CLI table utilities. You can configure using strings or objects for more control. Tablur also has a handy shorthand syntax that's a little easier to look at than using multiple objects for columns.

const table = new Tablur();

table
  .section('Tablur CLI Tables', 'center')

  .break()

  .row([
    { text: 'app run --dev' },
    { text: 'Runs the app.' },
    { text: 'Alias: r', align: 'right' }])

  .row(
    [{ text: 'app create <name>' },
    { text: 'Creates an app.' },
    { text: 'Alias: c', align: 'right' }])

  .break()

  .section('Options:\n', 'left')

  .row(
    [{ text: ' <name>' },
    { text: 'App name to create.' },
    { text: '[string] [required]', align: 'right' }])

  .row(
    [{ text: ' --dev, -d' },
    { text: 'Runs in dev mode.' },
    { text: '[boolean]', align: 'right' }])

  .break()

  .section({ text: '© 2018 Tablur', align: 'center' });


// Render to string and return.
const result = table.toString();

// OR

// Output to specified writable stream.
table.render(true);

Shorthand

Tablur has handy shorthand that is a little easier to look at than a bunch of objects. Using column configuration objects still gives the best control but using shorthand works well for simpler solutions and is a bit quicker to write.

Here's the order

text|width|align|padding

OR

text|align|padding

table.row('Some Title|center');

// use : for padding order is top, right, bottom, left
table.row('Username|30|left|0:1:0:1', 'Email|50');

Debug

What to know what's going on with Tablur's output? Create table passing in "true" to show padding, alignment and shifting. This was used during development but found it so handy just left it in. If something isn't responding as you expect give it a try, it will do one of two things. 1) Help you adjust your column or 2) show you a bug we need to fix!

const table = new Tablur(true);

// OR

const table = new Tablur({ /* options here */ }, true);

Characters

A - Represents alignment padding. P - Represents padding. S - Represents shifted text at boundary. > - Represents indent spaces.

╭──────────────────────────────────────────────────────────╮
│Root Path:AAAAAAAA │ .myappAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA│
│──────────────────────────────────────────────────────────│
│Import Path:AAAAAA │ dist/myapp.jsAAAAAAAAAAAAAAAAAAAAAAAA│
│──────────────────────────────────────────────────────────│
│Source Path:AAAAAA │ src/myapp.tsAAAAAAAAAAAAAAAAAAAAAAAAA│
│──────────────────────────────────────────────────────────│
│Output Path:AAAAAA │ srcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA│
│──────────────────────────────────────────────────────────│
│Template:AAAAAAAAA │ my.template.jsAAAAAAAAAAAAAAAAAAAAAAA│
╰──────────────────────────────────────────────────────────╯

Options

A quick note on "padding". The vertical padding is not 1 to 1. This is because it gets pretty huge when you do that. Hence verticle padding is divided by 2. This looks a little better when scaling padding. Just keep that in mind.

API

The Tablur API is very simple. You can add columns as strings with shorthand or as objects.

row

Adds a new row to the table. See Docs for more on method arguments.

section

Creates a section header. Similar to row but with some opinions most commonly used for this purpose. See Docs for more on method arguments.

repeat

Repeats a string in a row. For example if you wanted to have a row with *************************. See Docs for more on method arguments.

break

Adds an empty break row to the table.

toString

Renders the table and returns string representation.

render

Renders the table and writes to output stream. Pass true to wrap output in new lines for spacing.

clear

Clears the current rows but maintains options.

reset

Clears rows and resets all options, optionally can provide new options and debug mode.

Docs

See https://blujedis.github.io/tablur/

Change

See CHANGE.md

License

See LICENSE.md