Skip to main content

Type Alias: MappedTableField<T>

MappedTableField<T>: object

A mapped table field. A field with a label and a mapping function.

Type Parameters

T

The type of the objects in the array in the table.

Type declaration

label

label: string

mapFn()

mapFn: (el) => string | object

Parameters

el: T

Returns

string | object

Example

const items = [{name: 'Alice', age: 30}, {name: 'Bob', age: 40}];
console.log(table(items, [{label: 'Name', mapFn: (el) => el.name}, {label: 'Dog Age', mapFn: (el) => el.age * 7}]));
// Prints:
//
// | Name | Age |
// | ---- | --- |
// | Alice | 210 |
// | Bob | 280 |

Defined in

lib/markdown.ts:248