Function parseStringToArraySyncWASM

  • Beta

    Parse CSV string to record of arrays.

    Type Parameters

    • Header extends readonly string[]

    Parameters

    Returns CSVRecord<Header>[]

    Record of arrays

    Remarks

    This function uses WebAssembly to parse CSV string. Before calling this function, you must call loadWASM function.

    This function only supports UTF-8 string. If you pass a string that is not UTF-8, like UTF-16, it throws an error. This function only supports double quote as quotation. So, options.quotation must be " (double quote). Otherwise, it throws an error.

    And this function only supports single character as delimiter. So, options.delimiter must be a single character. Otherwise, it throws an error.

    Example

    import { loadWASM, parseStringWASM } from "web-csv-toolbox";

    await loadWASM();

    const csv = "a,b,c\n1,2,3";

    const result = parseStringToArraySyncWASM(csv);
    console.log(result);
    // Prints:
    // [{ a: "1", b: "2", c: "3" }]

Generated using TypeDoc