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

    Type Alias CSVRecord<Header, Format, Strategy>

    CSVRecord: Format extends "array"
        ? CSVArrayRecord<Header, Strategy>
        : CSVObjectRecord<Header>

    CSV Record.

    Type Parameters

    • Header extends ReadonlyArray<string>

      Header of the CSV.

    • Format extends "object" | "array" = "object"

      Output format: 'object' or 'array' (default: 'object')

    • Strategy extends ColumnCountStrategy = "keep"

      Column count strategy for array format (default: 'keep')

    This type represents a single CSV record, which can be either an object or an array depending on the Format type parameter.

    For array format, the Strategy parameter affects field types:

    • 'pad': Fields are typed as string | undefined
    • Other strategies: Fields are typed as string
    const record: CSVRecord<["foo", "bar"]> = {
    foo: "1",
    bar: "2",
    };
    const header = ["foo", "bar"] as const;
    const record: CSVRecord<typeof header, 'array'> = ["1", "2"];
    // Type: readonly [foo: string, bar: string]
    const header = ["foo", "bar"] as const;
    const record: CSVRecord<typeof header, 'array', 'pad'> = ["1", undefined];
    // Type: readonly [foo: string | undefined, bar: string | undefined]