0.0.3 • Published 6 years ago

tabl v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Tabl

Codeship Status for codeblaan/tabl

Super simple way to create a table in node. Most useful for command line tools written in node where you want to print out some stuff.

Install

yarn add tabl or npm install tabl

Develop

yarn install

Test

yarn test

Examples

yarn examples

Printing out some words all nice like

const Tabl = require('tabl')

const loremTabl = new Tabl([
  new Tabl.Column('Lorem', {width: 9}),
  new Tabl.Column('Ipsom', {width: 11}),
  new Tabl.Column('Dolor', {width: 5}),
], [
  ['sit', 'amet', 'consectetur'],
  ['adipiscing', 'elit', 'sed'],
  ['do', 'eiusmod', 'tempor'],
  ['incididunt', 'ut', 'labore'],
  ['et', 'dolore', 'magna'],
])
console.log(loremTabl.toString())
  Lorem     Ipsom       Dolor

  sit       amet        cons…
  adipisci… elit        sed
  do        eiusmod     temp…
  incididu… ut          labo…
  et        dolore      magna

And some numbers

const Tabl = require('tabl')

const numTabl = new Tabl([
  new Tabl.Column('One', {width: 9, align: 'right'}),
  new Tabl.Column('Two', {width: 9, align: 'right'}),
  new Tabl.Column('Three', {width: 10, align: 'right'}),
  new Tabl.Column('Four', {width: 9, align: 'right'}),
], [
  [91.472, 49.539, 7.807, 88.139],
  [9.255, 26.788, 46.567, 93.966],
  [83.141, 0.235, 9.844, 0.138],
  [44.625, '41.934', 17.043, 5.616],
])
console.log(numTabl.toString())
        One       Two      Three      Four

     91.472    49.539      7.807    88.139
      9.255    26.788     46.567    93.966
     83.141     0.235      9.844     0.138
     44.625    41.934     17.043     5.616