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

    Type Alias CSVArrayRecord<Header, Strategy>

    CSVArrayRecord: Header extends readonly []
        ? readonly string[]
        : Strategy extends "pad"
            ? { readonly [K in keyof Header]: string
            | undefined }
            : { readonly [K in keyof Header]: string }

    CSV record as an array (named tuple format).

    Type Parameters

    • Header extends ReadonlyArray<string>

      Header of the CSV.

    • Strategy extends ColumnCountStrategy = "keep"

      Column count strategy that affects field types (default: 'keep')

    This type represents a single CSV record as a readonly array. When a header is provided, it creates a named tuple with type-safe indexing. Without a header, it's a variable-length readonly string array.

    Type safety with columnCountStrategy:

    • 'keep', 'strict', 'truncate': Fields are typed as string
    • 'pad': Fields are typed as string | undefined (missing fields padded with undefined)
    const header = ["name", "age", "city"] as const;

    type Row = CSVArrayRecord<typeof header>;
    // readonly [name: string, age: string, city: string]

    const row: Row = ["Alice", "30", "NY"];
    row[0]; // name: string (type-safe!)
    row.length; // 3 (compile-time constant)
    const header = ["name", "age", "city"] as const;

    type Row = CSVArrayRecord<typeof header, 'pad'>;
    // readonly [name: string | undefined, age: string | undefined, city: string | undefined]

    const row: Row = ["Alice", "30", undefined]; // Type-safe!
    row[2]; // city: string | undefined
    type Row = CSVArrayRecord<readonly []>;
    // readonly string[]

    const row: Row = ["Alice", "30"];
    row[0]; // string
    row.length; // number (runtime determined)