tablemark
Generate markdown tables from JSON data.
Parses arrays of objects into markdown tables, complete with configuration
for renaming columns and left, center, or right-aligning them.
installation
npm i tablemark
usage
const tablemark = require('tablemark')
tablemark([
{ name: 'Bob', age: 21, isCool: false },
{ name: 'Sarah', age: 22, isCool: true },
{ name: 'Lee', age: 23, isCool: true }
])
... displays as:
name | age | isCool |
---|
Bob | 21 | false |
Sarah | 22 | true |
Lee | 23 | true |
tablemark([
{ name: 'Bob', age: 21, isCool: false },
{ name: 'Sarah', age: 22, isCool: true },
{ name: 'Lee', age: 23, isCool: true }
], {
columns: [
'first name',
{ name: 'how old', align: 'center' },
'are they cool'
]
})
... displays as:
first name | how old | are they cool |
---|
Bob | 21 | false |
Sarah | 22 | true |
Lee | 23 | true |
api
tablemark
tablemark(input, [options = {}])
Arguments
{Array<Object>} input
: the data to table-ify{Object} [options = {}]
key | type | default | description |
---|
columns | <Array> | - | Array of column descriptors. |
The columns
array can either contain objects, in which case their
name
and align
properties will be used to alter the display of
the column in the table, or any other type which will be coerced
to a string if necessary and used as a replacement for the column
name.
see also
license
MIT © Bo Lingen / citycide