obj-to-table
v2.0.0
Published
Create a table from an array of objects
Downloads
7
Readme
obj-to-table
Create a table from an array of objects
Install
$ npm install --save obj-to-table
Usage
const objToTable = require('obj-to-table');
const table = objToTable([{
foo: 'bar',
cat: 'meow',
unicorn: 'moo'
}, {
foo: 'crow',
cat: 'eek',
unicorn: 'buzz'
}, {
foo: 'ow',
cat: 'hee-haw',
unicorn: 'hum'
}]);
console.log(table.toString());
/*
┌──────────────┬──────────────┬──────────────┐
│ foo │ cat │ unicorn │
├──────────────┼──────────────┼──────────────┤
│ bar │ meow │ moo │
├──────────────┼──────────────┼──────────────┤
│ crow │ eek │ buzz │
├──────────────┼──────────────┼──────────────┤
│ ow │ hee-haw │ hum │
└──────────────┴──────────────┴──────────────┘
*/
API
objToTable(data, [options])
data
Type: Array
Object
An array of objects containing your data.
options
Type: Object
See the cli-table options.
License
MIT © Kevin Martensson