CLI table + auxiliary TTY write utils like dim, bold, newline and arrow
npm install tableaux
tableaux(...columnHeader) => writeFn
The columnHeader
is an object which can have the following possible properties:
name
(string), requiredsize
(number)align
(string), 'left', 'right' or 'center', default='left'color
(string or function),function(val, row) { return color; }
format
(function),function(val, row) { return newVal; }
Multiple column headers can be passed,
tableaux({name: 'Title'}, {name: 'Author'}, {name: 'ISBN'})
The returned value is a function, each argument corresponds to a column,
var write = tableaux({name: 'Title'}, {name: 'Author'}, {name: 'ISBN'})
write('War and Peace', 'Leo Tolstoy', 9789722219242)
The writeFn
also has several convenience methods
Output the string with the dim ANSI escape code
Output the string with the bright ANSI escape code
Write a newline character (\n
)
Write n
number of spaces
Output a ↳
character, specify leftPad
and rightPad
params
for padding around the arrow
var tableaux = require('tableaux')
var write = tableaux({name: 'Title'}, {name: 'Author'}, {name: 'ISBN'})
write('War and Peace', 'Leo Tolstoy', '9789722219242')
alts(['9783538065437', '9781586638146', '9788495303509'])
write('Gone with the Wind', 'Margaret Mitchell', '9789630753661')
alts(['9784794600448', '9783548248820', '9785750706471'])
write.newline()
function alts(isbns) {
write.arrow()
write.bold('Alt ISBNS')
isbns.forEach(write.dim)
write.newline()
}
MIT
- sponsored by nearForm