diff options
author | uki00a <uki00a@gmail.com> | 2020-09-28 03:20:46 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-27 14:20:46 -0400 |
commit | 94dcef714d09e09cd7eb777396f954ac3d24b161 (patch) | |
tree | ffc2c2da074c6d22813f0c6f964f72c2e6f1d8be /std/encoding/README.md | |
parent | 5db72dcaf364d0a9d9a5c5c9c10e80cdf8a199ad (diff) |
BREAKING(std/encoding/csv): improve the definition of ParseOptions (#7714)
Diffstat (limited to 'std/encoding/README.md')
-rw-r--r-- | std/encoding/README.md | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/std/encoding/README.md b/std/encoding/README.md index 21797a451..2f0ac91f1 100644 --- a/std/encoding/README.md +++ b/std/encoding/README.md @@ -37,25 +37,29 @@ writeVarbig(w: Deno.Writer, x: bigint, o: VarbigOptions = {}): Promise<number> Parse the CSV from the `reader` with the options provided and return `string[][]`. -#### `parse(input: string | BufReader, opt: ParseOptions = { header: false }): Promise<unknown[]>`: +#### `parse(input: string | BufReader, opt: ParseOptions = { skipFirstRow: false }): Promise<unknown[]>`: Parse the CSV string/buffer with the options provided. The result of this function is as follows: -- If you don't provide both `opt.header` and `opt.parse`, it returns - `string[][]`. -- If you provide `opt.header` but not `opt.parse`, it returns `object[]`. +- If you don't provide `opt.skipFirstRow`, `opt.parse`, and `opt.columns`, it + returns `string[][]`. +- If you provide `opt.skipFirstRow` or `opt.columns` but not `opt.parse`, it + returns `object[]`. - If you provide `opt.parse`, it returns an array where each element is the value returned from `opt.parse`. ##### `ParseOptions` -- **`header: boolean | string[] | HeaderOptions[];`**: If a boolean is provided, - the first line will be used as Header definitions. If `string[]` or - `HeaderOptions[]` those names will be used for header definition. +- **`skipFirstRow: boolean;`**: If you provide `skipFirstRow: true` and + `columns`, the first line will be skipped. If you provide `skipFirstRow: true` + but not `columns`, the first line will be skipped and used as header + definitions. +- **`columns: string[] | HeaderOptions[];`**: If you provide `string[]` or + `ColumnOptions[]`, those names will be used for header definition. - **`parse?: (input: unknown) => unknown;`**: Parse function for the row, which will be executed after parsing of all columns. Therefore if you don't provide - header and parse function with headers, input will be `string[]`. + `skipFirstRow`, `columns`, and `parse` function, input will be `string[]`. ##### `HeaderOptions` |