Repository navigation
modules
web-csv-toolbox / Exports
Ƭ CSVRecord<Header>: Record<Header[number], string>
CSV Record.
Example
const record: CSVRecord<["foo", "bar"]> = {
foo: "1",
bar: "2",
};| Name | Type | Description |
|---|---|---|
Header |
extends ReadonlyArray<string> |
Header of the CSV. |
Ƭ TokenType: typeof FieldDelimiter | typeof RecordDelimiter | typeof Field
Type of a token for CSV.
• Const Field: typeof Field
Field is a symbol for field of CSV.
• Const FieldDelimiter: typeof FieldDelimiter
FiledDelimiter is a symbol for field delimiter of CSV.
• Const RecordDelimiter: typeof RecordDelimiter
RecordDelimiter is a symbol for record delimiter of CSV.
▸ parse<Header>(csv, options?): AsyncIterableIterator<CSVRecord<Header>>
Parse CSV to records.
String, Uint8Array, ReadableStream<string | Uint8Array> and Response are supported.
| Name | Type |
|---|---|
Header |
extends readonly string[] |
| Name | Type | Description |
|---|---|---|
csv |
string | Response | ReadableStream<string | Uint8Array> |
CSV string to parse |
options? |
ParseOptions<Header> |
Parsing options. See ParseOptions. |
AsyncIterableIterator<CSVRecord<Header>>
Remarks
streamingParse, parseBinaryStream, parseStringStream and parseResponse are used internally. If you known the type of the stream, it performs better to use them directly.
If you want to parse a string, use streamingParse. If you want to parse a Uint8Array, use parseStream. If you want to parse a ReadableStream, use parseStringStream. If you want to parse a ReadableStream, use parseBinaryStream. If you want to parse a Response, use parseResponse.
▸ parseBinaryStream<Header>(stream, options?): AsyncIterableIterator<CSVRecord<Header>>
Parse CSV to records. This function is for parsing a binary stream.
| Name | Type |
|---|---|
Header |
extends readonly string[] |
| Name | Type | Description |
|---|---|---|
stream |
ReadableStream<Uint8Array> |
CSV string to parse |
options? |
ParseBinaryOptions<Header> |
Parsing options. See ParseBinaryOptions. |
AsyncIterableIterator<CSVRecord<Header>>
Remarks
If you want to parse a string, use streamingParse.
▸ parseStringStream<Header>(stream, options?): AsyncIterableIterator<CSVRecord<Header>>
Parse CSV string to records.
| Name | Type |
|---|---|
Header |
extends readonly string[] |
| Name | Type | Description |
|---|---|---|
stream |
ReadableStream<string> |
CSV string stream to parse |
options? |
ParseOptions<Header> |
Parsing options. See ParseOptions. |
AsyncIterableIterator<CSVRecord<Header>>
▸ streamingParse<Header>(csv, options?): AsyncIterableIterator<CSVRecord<Header>>
Parse CSV string to records.
| Name | Type |
|---|---|
Header |
extends readonly string[] |
| Name | Type | Description |
|---|---|---|
csv |
string |
CSV string to parse |
options? |
ParseOptions<Header> |
Parsing options. See ParseOptions. |
AsyncIterableIterator<CSVRecord<Header>>