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

    Type Alias CSVObjectRecord<Header, Strategy>

    CSVObjectRecord: Strategy extends "sparse"
        ? never
        : Record<Header[number], string>

    CSV record as an object (traditional format).

    Type Parameters

    • Header extends ReadonlyArray<string>

      Header of the CSV.

    • Strategy extends ObjectFormatColumnCountStrategy = "fill"

      Column count strategy (must not be 'sparse', default: 'fill')

    This type represents a single CSV record as an object, where each key corresponds to a header field and the value is the field's string content.

    Important: Object format does NOT support 'sparse' strategy. Using 'sparse' with object format will result in a type error at compile time and a runtime error if attempted. All strategies for object format produce string values (never undefined).

    const header = ["foo", "bar"];

    type Record = CSVObjectRecord<typeof header>;
    // { foo: string; bar: string }

    const record: Record = { foo: "1", bar: "2" };
    // This will cause a type error because 'sparse' is not allowed
    type InvalidRecord = CSVObjectRecord<["a", "b"], "sparse">;
    // Error: Type '"sparse"' does not satisfy the constraint 'ObjectFormatColumnCountStrategy'