lihai 8d6c751f49 feat: push | %!s(int64=2) %!d(string=hai) anos | |
---|---|---|
.. | ||
example | %!s(int64=2) %!d(string=hai) anos | |
test | %!s(int64=2) %!d(string=hai) anos | |
.travis.yml | %!s(int64=2) %!d(string=hai) anos | |
LICENSE | %!s(int64=2) %!d(string=hai) anos | |
index.js | %!s(int64=2) %!d(string=hai) anos | |
package.json | %!s(int64=2) %!d(string=hai) anos | |
readme.markdown | %!s(int64=2) %!d(string=hai) anos |
generate borderless text table strings suitable for printing to stdout
var table = require('text-table');
var t = table([
[ 'master', '0123456789abcdef' ],
[ 'staging', 'fedcba9876543210' ]
]);
console.log(t);
master 0123456789abcdef
staging fedcba9876543210
var table = require('text-table');
var t = table([
[ 'beep', '1024' ],
[ 'boop', '33450' ],
[ 'foo', '1006' ],
[ 'bar', '45' ]
], { align: [ 'l', 'r' ] });
console.log(t);
beep 1024
boop 33450
foo 1006
bar 45
var table = require('text-table');
var t = table([
[ 'beep', '1024' ],
[ 'boop', '334.212' ],
[ 'foo', '1006' ],
[ 'bar', '45.6' ],
[ 'baz', '123.' ]
], { align: [ 'l', '.' ] });
console.log(t);
beep 1024
boop 334.212
foo 1006
bar 45.6
baz 123.
var table = require('text-table');
var t = table([
[ 'beep', '1024', 'xyz' ],
[ 'boop', '3388450', 'tuv' ],
[ 'foo', '10106', 'qrstuv' ],
[ 'bar', '45', 'lmno' ]
], { align: [ 'l', 'c', 'l' ] });
console.log(t);
beep 1024 xyz
boop 3388450 tuv
foo 10106 qrstuv
bar 45 lmno
var table = require('text-table')
Return a formatted table string s
from an array of rows
and some options
opts
.
rows
should be an array of arrays containing strings, numbers, or other
printable values.
options can be:
opts.hsep
- separator to use between columns, default ' '
opts.align
- array of alignment types for each column, default ['l','l',...]
opts.stringLength
- callback function to use when calculating the string lengthalignment types are:
'l'
- left'r'
- right'c'
- center'.'
- decimalWith npm do:
npm install text-table
Since the string length of ANSI color schemes does not equal the length JavaScript sees internally it is necessary to pass the a custom string length calculator during the main function call.
See the test/ansi-colors.js
file for an example.
MIT