web-csv-toolbox - v0.15.0
    Preparing search index...

    Interface CSVRecordAssemblerFactoryOptions<Header, OutputFormat, Strategy>

    Options for creating a CSV record assembler via factory function.

    interface CSVRecordAssemblerFactoryOptions<
        Header extends ReadonlyArray<string>,
        OutputFormat extends CSVOutputFormat = CSVOutputFormat,
        Strategy extends ColumnCountStrategy = ColumnCountStrategy,
    > {
        columnCountStrategy?: Strategy;
        engine?: EngineConfig;
        header?: Header;
        includeHeader?: boolean;
        maxFieldCount?: number;
        outputFormat?: OutputFormat;
        signal?: AbortSignal;
        skipEmptyLines?: boolean;
        source?: string;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    columnCountStrategy?: Strategy
    engine?: EngineConfig

    Engine configuration for CSV parsing.

    parse(csv)
    
    parse(csv, { engine: { worker: true } })
    
    await loadWASM();
    parse(csv, { engine: { worker: true, wasm: true } })
    parse(csv, {
    engine: {
    worker: true,
    workerStrategy: "stream-transfer"
    }
    })
    header?: Header
    includeHeader?: boolean
    maxFieldCount?: number
    outputFormat?: OutputFormat
    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
    source?: string

    Source identifier for error reporting (e.g., filename, description).

    This option allows you to specify a human-readable identifier for the CSV source that will be included in error messages. This is particularly useful when parsing multiple files or streams to help identify which source caused an error.

    Security Note: Do not include sensitive information (API keys, tokens, full URLs) in this field as it may be exposed in error messages and logs.

    parseString(csv, { source: "users.csv" });
    // Error: Field count exceeded at row 5 in "users.csv"
    undefined