Closed larswaechter closed 1 year ago
Improved the type system as mentioned in #2. Moreover there are some breaking API changes:
header.names
header.displayNames
header.columns
header.include
header.exclude
body.subset
accumulation.columns
header.dynamic
removeColumn
shuffle
The GitBook documentation must be updated.
An example:
import { AccumulationFunction, Table } from '.'; const data = [ { firstname: 'Homer', lastname: 'Simpson', age: 39 }, { firstname: 'Marge', lastname: 'Simpson', age: 36 }, { firstname: 'Bart', lastname: 'Simpson', age: 10 }, { firstname: 'Lisa', lastname: 'Simpson', age: 8 }, { firstname: 'Maggie', lastname: 'Simpson', age: 1 } ]; interface IDynamicAttributes { fullname: string; } const table = new Table<(typeof data)[number], IDynamicAttributes>(data, { header: { dynamic: { fullname(row) { return row.firstname + ' ' + row.lastname; } } }, body: { accumulation: { columns: { age: AccumulationFunction.SUM } } } }); table.print();
Improved the type system as mentioned in #2. Moreover there are some breaking API changes:
header.names
=>header.displayNames
to avoid confusionheader.columns
=>header.include
header.exclude
to exclude certain columnsbody.subset
to select only a subset as datasetaccumulation.columns
=> Takes now an object where the keys are the target column nameheader.dynamic
=> Takes now an object where the keys are the dynamic column namesremoveColumn
andshuffle
methodsThe GitBook documentation must be updated.
An example: