web-csv-toolbox
    Preparing search index...

    Interface ParseBinaryOptions<Header>

    Parse options for CSV binary.

    interface ParseBinaryOptions<Header extends ReadonlyArray<string>> {
        charset?: string;
        decomposition?: CompressionFormat;
        delimiter?: ",";
        fatal?: boolean;
        header?: Header;
        ignoreBOM?: boolean;
        quotation?: "\"";
        signal?: AbortSignal;
    }

    Type Parameters

    • Header extends ReadonlyArray<string>

    Hierarchy (View Summary)

    Index

    Properties

    charset?: string

    You can specify the character encoding of the binary.

    TextDecoderStream is used internally.

    See Encoding API Compatibility for the encoding formats that can be specified.

    'utf-8'
    
    decomposition?: CompressionFormat

    If the binary is compressed by a compression algorithm, the decompressed CSV can be parsed by specifying the algorithm.

    Make sure the runtime you are running supports stream decompression.

    See DecompressionStream Compatibility.

    delimiter?: ","

    CSV field delimiter. If you want to parse TSV, specify '\t'.

    Detail restrictions are as follows:

    • Must not be empty
    • Must be a single character
      • Multi-byte characters are not supported
    • Must not include CR or LF
    • Must not be the same as the quotation
    ','
    
    fatal?: boolean

    If the binary has a invalid character, you can specify whether to throw an error.

    If the property is true then a decoder will throw a TypeError if it encounters malformed data while decoding.

    If false the decoder will substitute the invalid data with the replacement character U+FFFD (�).

    See TextDecoderOptions.fatal for more information.

    false
    
    header?: Header

    CSV header.

    If you specify this option, the first record will be treated as a normal record.

    If you don't specify this option, the first record will be treated as a header.

    undefined
    
    ignoreBOM?: boolean

    If the binary has a BOM, you can specify whether to ignore it.

    If you specify true, the BOM will be ignored. If you specify false or not specify it, the BOM will be treated as a normal character. See TextDecoderOptions.ignoreBOM for more information about the BOM.

    false
    
    quotation?: "\""

    CSV field quotation.

    '"'
    
    signal?: AbortSignal

    The signal to abort the operation.

    If the signal is aborted, the operation will be stopped.

    const controller = new AbortController();

    const csv = "foo,bar\n1,2\n3,4";
    try {
    const result = await parse(csv, { signal: controller.signal });
    } catch (e) {
    if (e instanceof DOMException && e.name === "AbortError") {
    console.log("Aborted");
    }
    }

    // Abort with user action
    document.getElementById("cancel-button")
    .addEventListener("click", () => {
    controller.abort();
    });
    const csv = "foo,bar\n1,2\n3,4";

    try {
    const result = await parse(csv, { signal: AbortSignal.timeout(1000) });
    } catch (e) {
    if (e instanceof DOMException && e.name === "TimeoutError") {
    console.log("Timeout");
    }
    }
    undefined