Skip to content
This repository was archived by the owner on Nov 20, 2019. It is now read-only.

Olian04/ToTable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToTable is a tiny no-config-needed-library that generates html tables from arrays of objects.

Theres no funny businesses, no dependencies, no transpilation, just ~50 lines of vanilla js.

Demo Fiddle

NPM

npm i --save totable

CDN

<script src="https://unpkg.com/totable"></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 }
]);
Firstname Lastname Age
Oliver Twist 14
Charles Darwin 78
Steven Hawkins 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 }
]);
Lastname Age
Twist 14
Darwin 78
Hawkins 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 }
]);
name age
Oliver 14
Charles 78
Steven 50

About

A tiny library that generates html tables from arrays of objects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors