mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 20:25:12 -05:00
fix(std/encoding/csv): Correct readme formatting due to dprint issues (#8503)
This commit is contained in:
parent
85a5a081b2
commit
01e87119ea
1 changed files with 38 additions and 35 deletions
|
@ -102,31 +102,32 @@ function is as follows:
|
||||||
|
|
||||||
`DataItem: Record<string, unknown> | unknown[]`
|
`DataItem: Record<string, unknown> | unknown[]`
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
name: "Deno",
|
name: "Deno",
|
||||||
repo: { org: "denoland", name: "deno" },
|
repo: { org: "denoland", name: "deno" },
|
||||||
runsOn: ["Rust", "TypeScript"],
|
runsOn: ["Rust", "TypeScript"],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
- **`columns`** is a list of instructions for how to target and transform the
|
- **`columns`** is a list of instructions for how to target and transform the
|
||||||
data for each column of output. This is also where you can provide an explicit
|
data for each column of output. This is also where you can provide an explicit
|
||||||
header name for the column.
|
header name for the column.
|
||||||
|
|
||||||
`Column`:
|
`Column`:
|
||||||
|
|
||||||
- The most essential aspect of a column is accessing the property holding the
|
- 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
|
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
|
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).
|
`string` (if it's a plain object) or a `number` (if it's an array).
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const columns = [
|
const columns = [
|
||||||
"name",
|
"name",
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
Each property accessor will be used as the header for the column:
|
Each property accessor will be used as the header for the column:
|
||||||
|
|
||||||
|
@ -138,12 +139,12 @@ function is as follows:
|
||||||
objects/arrays), then a simple property accessor won't work, so an array of
|
objects/arrays), then a simple property accessor won't work, so an array of
|
||||||
them will be required.
|
them will be required.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const columns = [
|
const columns = [
|
||||||
["repo", "name"],
|
["repo", "name"],
|
||||||
["repo", "org"],
|
["repo", "org"],
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
When using arrays of property accessors, the header names inherit the value
|
When using arrays of property accessors, the header names inherit the value
|
||||||
of the last accessor in each array:
|
of the last accessor in each array:
|
||||||
|
@ -158,27 +159,29 @@ function is as follows:
|
||||||
|
|
||||||
- **`fn?: (value: any) => string | Promise<string>`** is an optional
|
- **`fn?: (value: any) => string | Promise<string>`** is an optional
|
||||||
function to transform the targeted data into the desired format
|
function to transform the targeted data into the desired format
|
||||||
|
|
||||||
- **`header?: string`** is the optional value to use for the column header
|
- **`header?: string`** is the optional value to use for the column header
|
||||||
name
|
name
|
||||||
|
|
||||||
- **`prop: PropertyAccessor | PropertyAccessor[]`** is the property accessor
|
- **`prop: PropertyAccessor | PropertyAccessor[]`** is the property accessor
|
||||||
(`string` or `number`) or array of property accessors used to access the
|
(`string` or `number`) or array of property accessors used to access the
|
||||||
data on each object
|
data on each object
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const columns = [
|
const columns = [
|
||||||
"name",
|
"name",
|
||||||
{
|
{
|
||||||
prop: ["runsOn", 0],
|
prop: ["runsOn", 0],
|
||||||
header: "language 1",
|
header: "language 1",
|
||||||
fn: (str: string) => str.toLowerCase(),
|
fn: (str: string) => str.toLowerCase(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: ["runsOn", 1],
|
prop: ["runsOn", 1],
|
||||||
header: "language 2",
|
header: "language 2",
|
||||||
fn: (str: string) => str.toLowerCase(),
|
fn: (str: string) => str.toLowerCase(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
| name | language 1 | language 2 |
|
| name | language 1 | language 2 |
|
||||||
| :--: | :--------: | :--------: |
|
| :--: | :--------: | :--------: |
|
||||||
|
|
Loading…
Add table
Reference in a new issue