web-csv-toolbox
    Preparing search index...

    Interface CSVRecordAssemblerOptions<Header>

    CSV Record Assembler Options.

    If you specify header: ['foo', 'bar'], the first record will be treated as a normal record.

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

    interface CSVRecordAssemblerOptions<Header extends ReadonlyArray<string>> {
        header?: Header;
        maxFieldCount?: number;
        signal?: AbortSignal;
        skipEmptyLines?: boolean;
    }

    Type Parameters

    • Header extends ReadonlyArray<string>

    Hierarchy (View Summary)

    Index

    Properties

    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
    
    maxFieldCount?: number

    Maximum number of fields allowed per record.

    This option limits the number of columns/fields in a CSV record to prevent memory exhaustion attacks. When a record exceeds this limit, a FieldCountLimitError will be thrown.

    Set to Number.POSITIVE_INFINITY to disable the limit (not recommended for untrusted input).

    100000
    
    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
    
    skipEmptyLines?: boolean

    When true, completely empty lines (with only delimiters or whitespace) will be skipped during parsing.

    false