Skip to content

modules

github-actions[bot] edited this page Dec 25, 2023 · 1 revision

web-csv-toolbox / Exports

web-csv-toolbox

Table of contents

Namespaces

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

CSVRecord

Ƭ CSVRecord<Header>: Record<Header[number], string>

CSV Record.

Example

const record: CSVRecord<["foo", "bar"]> = {
  foo: "1",
  bar: "2",
};

Type parameters

Name Type Description
Header extends ReadonlyArray<string> Header of the CSV.

Defined in

src/common/types.ts:149


TokenType

Ƭ TokenType: typeof FieldDelimiter | typeof RecordDelimiter | typeof Field

Type of a token for CSV.

Defined in

src/common/types.ts:22

Variables

Field

• Const Field: typeof Field

Field is a symbol for field of CSV.

Defined in

src/common/constants.ts:12


FieldDelimiter

• Const FieldDelimiter: typeof FieldDelimiter

FiledDelimiter is a symbol for field delimiter of CSV.

Defined in

src/common/constants.ts:4


RecordDelimiter

• Const RecordDelimiter: typeof RecordDelimiter

RecordDelimiter is a symbol for record delimiter of CSV.

Defined in

src/common/constants.ts:8

Functions

parse

▸ parse<Header>(csv, options?): AsyncIterableIterator<CSVRecord<Header>>

Parse CSV to records.

String, Uint8Array, ReadableStream<string | Uint8Array> and Response are supported.

Type parameters

Name Type
Header extends readonly string[]

Parameters

Name Type Description
csv string | Response | ReadableStream<string | Uint8Array> CSV string to parse
options? ParseOptions<Header> Parsing options. See ParseOptions.

Returns

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.

Defined in

src/parse.ts:28


parseBinaryStream

▸ parseBinaryStream<Header>(stream, options?): AsyncIterableIterator<CSVRecord<Header>>

Parse CSV to records. This function is for parsing a binary stream.

Type parameters

Name Type
Header extends readonly string[]

Parameters

Name Type Description
stream ReadableStream<Uint8Array> CSV string to parse
options? ParseBinaryOptions<Header> Parsing options. See ParseBinaryOptions.

Returns

AsyncIterableIterator<CSVRecord<Header>>

Remarks

If you want to parse a string, use streamingParse.

Defined in

src/parseBinaryStream.ts:14


parseStringStream

▸ parseStringStream<Header>(stream, options?): AsyncIterableIterator<CSVRecord<Header>>

Parse CSV string to records.

Type parameters

Name Type
Header extends readonly string[]

Parameters

Name Type Description
stream ReadableStream<string> CSV string stream to parse
options? ParseOptions<Header> Parsing options. See ParseOptions.

Returns

AsyncIterableIterator<CSVRecord<Header>>

Defined in

src/parseStringStream.ts:14


streamingParse

▸ streamingParse<Header>(csv, options?): AsyncIterableIterator<CSVRecord<Header>>

Parse CSV string to records.

Type parameters

Name Type
Header extends readonly string[]

Parameters

Name Type Description
csv string CSV string to parse
options? ParseOptions<Header> Parsing options. See ParseOptions.

Returns

AsyncIterableIterator<CSVRecord<Header>>

Defined in

src/streamingParse.ts:12

Clone this wiki locally