import { type Column } from "https://deno.land/std@0.186.0/csv/mod.ts";
The most essential aspect of a column is accessing the property holding the
data for that column on each object in the data array. If that member is at
the top level, Column
can simply be a property accessor, which is either a
string
(if it's a plain object) or a number
(if it's an array).
const columns = [
"name",
];
Each property accessor will be used as the header for the column:
name |
---|
Deno |
-
If the required data is not at the top level (it's nested in other objects/arrays), then a simple property accessor won't work, so an array of them will be required.
const columns = [ ["repo", "name"], ["repo", "org"], ];
When using arrays of property accessors, the header names inherit the value of the last accessor in each array:
name org deno denoland -
If a different column header is desired, then a
ColumnDetails
object type can be used for each column: -
header?: string
is the optional value to use for the column header name -
prop: PropertyAccessor | PropertyAccessor[]
is the property accessor (string
ornumber
) or array of property accessors used to access the data on each object
const columns = [
"name",
{
prop: ["runsOn", 0],
header: "language 1",
},
{
prop: ["runsOn", 1],
header: "language 2",
},
];
name | language 1 | language 2 |
---|---|---|
Deno | Rust | TypeScript |