totable
v1.1.0
Published
A tiny library that generates html tables from arrays of objects.
Downloads
5
Maintainers
Readme
ToTable
A tiny library that generates html tables from arrays of objects.
No funny businesses, no dependencies, no transpilation, just ~50 lines of vanilla js.
NPM
npm i --save totable
CDN
<script src="https://cdn.rawgit.com/Olian04/ToTable/d126873e/src/ToTable.js"></script>
ToTable(arrayOfObjects)
const ToTable = require('totable');
const html = ToTable([
{ firstname: 'Oliver', lastname: 'Twist', age: 14 },
{ firstname: 'Charles', lastname: 'Darwin', age: 78 },
{ firstname: 'Steven', lastname: 'Hawken', age: 50 }
]);
ToTable(arrayOfColumnNames, arrayOfObjects)
const ToTable = require('totable');
const html = ToTable(['lastname', 'age'], [
{ firstname: 'Oliver', lastname: 'Twist', age: 14 },
{ firstname: 'Charles', lastname: 'Darwin', age: 78 },
{ firstname: 'Steven', lastname: 'Hawken', age: 50 }
]);
ToTable(objectOfColumnNameMappings, arrayOfObjects)
const ToTable = require('totable');
const html = ToTable({
firstname: 'name',
age: 'age'
}, [
{ firstname: 'Oliver', lastname: 'Twist', age: 14 },
{ firstname: 'Charles', lastname: 'Darwin', age: 78 },
{ firstname: 'Steven', lastname: 'Hawken', age: 50 }
]);