JSPM

  • Created
  • Published
  • Downloads 1589323
  • Score
    100M100P100Q183171F
  • License MIT

A simple function to print objects as ASCII tables

Package Exports

  • as-table

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (as-table) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

as-table

A simple function that print objects as ASCII tables.

npm install as-table

Printing objects:

asTable = require ('as-table')

asTable ([ { foo: true,  string: 'abcde',      num: 42 },
           { foo: false, string: 'qwertyuiop', num: 43 },
           {             string:  null,        num: 44 } ])
foo    string      num
----------------------
true   abcde       42 
false  qwertyuiop  43 
       null        44 

Printing arrays:

asTable ([['qwe',       '123456789', 'zxcvbnm'],
          ['qwerty',    '12',        'zxcvb'],
          ['qwertyiop', '1234567',   'z']])
qwe        123456789  zxcvbnm
qwerty     12         zxcvb
qwertyiop  1234567    z

Limiting total width by proportionally trimming cells + setting columns delimiter:

asTable.configure ({ maxTotalWidth: 25, delimiter: ' | ' }) (data)
qwe   | 12345 | zxcv
qwert | 12    | zxcv
qwert | 12345 | z

Or you can do this:

asTable = require ('as-table').configure ({ maxTotalWidth: 25, delimiter: ' | ' })

asTable (data)