2.0.0 • Published 7 years ago

obj-to-table v2.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

obj-to-table Build Status

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