Zygon
Simple terminal table renderer
Usage:
zygon(columnsDefinition[, data][, options]);
columnsDefinition
- name (string), required
- key (string), required for rendering arrays of objects
- size (number or Infinity), default = options.size
- align (string), 'left', 'right' or 'center', default='left'
- color (string or function),
function(val, row) { return color; }
- format (function),
function(val, row) { return newVal; }
data
Array of arrays or array of objects (if "key" was defined for columns)
options
- size (number), default = 20
- spacing (number), spaces between columns, default = 2
- notBold (boolean), print heading without styles
- output (writable stream), default =
process.stdout
returns
an object
- printHead()
- printRow( array or object )
- printRows( array of arrays or objects )
- end()
Examples
var zygon=; ;
Actor Episodes
William Hartnell 134
Patrick Troughton 119
Jon Pertwee 128
Tom Baker 172
Render streamed data
var tbl=; tbl; tbl; tbl; tbl; tbl;
Actor Episodes
Tom Baker 172
Peter Davison 69
Colin Baker 31
Sylvester McCoy 42
Paul McGann 1
Arrays of objects / color and format functions / spacing option
;
Name Episodes Year
Christopher Eccleston 13 2005
David Tennant 47 2005-2010
Matt Smith 44 2010-2013
Peter Capaldi ? 2013-2016
Tests
Run tests with npm test
or generate coverage reports with npm run test-cov
.