Function
getColumnsFromData
(inferTypesFn: typeof inferTypes, data: object[], columnTypes?: ColumnTypeMap)
Source from the content-addressed store, hash-verified
| 18 | * @param data Array of data objects. |
| 19 | */ |
| 20 | export function getColumnsFromData(inferTypesFn: typeof inferTypes, data: object[], columnTypes?: ColumnTypeMap) { |
| 21 | const sample = data[0]; |
| 22 | const fields = sample ? Object.keys(sample) : []; |
| 23 | const inferences = { ...inferTypesFn(data, fields), ...columnTypes }; |
| 24 | const columns = fields.map(name => { |
| 25 | const column: Column = { |
| 26 | name, |
| 27 | type: inferences[name], |
| 28 | }; |
| 29 | return column; |
| 30 | }); |
| 31 | inferAll(columns, data); |
| 32 | return columns; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get columns associated with each Insight role. |
Tested by
no test coverage detected