stringTable.js
A groundbreaking, innovating JavaScript library to do something that's literally never been attempted before: formatting an array of data objects as a textual table.
var objects = [
{ name: 'Dan', gender: 'M', age: 29 },
{ name: 'Adam', gender: 'M', age: 31 },
{ name: 'Lauren', gender: 'F', age: 33 }
];
var table = stringTable.create(objects);
console.log(table);
You can also specify options to customize how the table is formatted:
var table = stringTable.create(objects, options);
The available options are summarized below.
Options
headers (e.g., ['name', 'age']): an array of strings indicating which column headers to include
formatters: an object mapping column names to formatter functions
outerBorder (default: '|'): the character(s) used to enclose the table
innerBorder (default: '|'): the character(s) used to delimit cells within the table