3 generate borderless text table strings suitable for printing to stdout
5 [![build status](https://secure.travis-ci.org/substack/text-table.png)](http://travis-ci.org/substack/text-table)
7 [![browser support](https://ci.testling.com/substack/text-table.png)](http://ci.testling.com/substack/text-table)
14 var table = require('text-table');
16 [ 'master', '0123456789abcdef' ],
17 [ 'staging', 'fedcba9876543210' ]
23 master 0123456789abcdef
24 staging fedcba9876543210
30 var table = require('text-table');
36 ], { align: [ 'l', 'r' ] });
50 var table = require('text-table');
53 [ 'boop', '334.212' ],
57 ], { align: [ 'l', '.' ] });
72 var table = require('text-table');
74 [ 'beep', '1024', 'xyz' ],
75 [ 'boop', '3388450', 'tuv' ],
76 [ 'foo', '10106', 'qrstuv' ],
77 [ 'bar', '45', 'lmno' ]
78 ], { align: [ 'l', 'c', 'l' ] });
92 var table = require('text-table')
95 ## var s = table(rows, opts={})
97 Return a formatted table string `s` from an array of `rows` and some options
100 `rows` should be an array of arrays containing strings, numbers, or other
105 * `opts.hsep` - separator to use between columns, default `' '`
106 * `opts.align` - array of alignment types for each column, default `['l','l',...]`
107 * `opts.stringLength` - callback function to use when calculating the string length
118 With [npm](https://npmjs.org) do:
121 npm install text-table
124 # Use with ANSI-colors
126 Since the string length of ANSI color schemes does not equal the length
127 JavaScript sees internally it is necessary to pass the a custom string length
128 calculator during the main function call.
130 See the `test/ansi-colors.js` file for an example.