obj-to-table

2.0.0 • Public • Published

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

Package Sidebar

Install

npm i obj-to-table

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • kevva