easy-table
easy-table copied to clipboard
Doesn't work with multi-line content
var Table = require('easy-table')
var data = [
{ id: 123123, desc: 'Something \nawesome', price: 1000.00 },
{ id: 245452, desc: 'Very interesting book', price: 11.45},
{ id: 232323, desc: 'Yet another product', price: 555.55 }
]
var t = new Table
data.forEach(function(product) {
t.cell('Product Id', product.id)
t.cell('Description', product.desc)
t.cell('Price, USD', product.price, Table.number(2))
t.newRow()
})
console.log(t.toString())
Product Id Description Price, USD
---------- --------------------- ----------
123123 Something
awesome 1000.00
245452 Very interesting book 11.45
232323 Yet another product 555.55
I was just looking for the same thing 😄 I guess that it would make it a great deal more complicated to detect line break and then format it after that.
It could just create a new row, but if more columns contain a newline, one row could generate multiple extra rows.