/** * `decodeColumns` — decode BRO's column time-series (space-separated rows of * comma-delimited columns: settlement steps, triaxial/direct-shear loading * stages, the CPT measurement block). * * A caller declares a typed column spec and gets typed rows back; the −999999 / * "NaN" sentinel→null rule lives here. Decodes the *content* of one leaf's CSV * text; the {@link columns} producer bridges it into the tree-shaped * {@link Producer} DSL. */ import type { CustomProducer } from "./producer.js"; /** Parse one CSV cell into a typed value. */ export type ColumnParser = (raw: string) => V; /** One column of a CSV time-series. */ export interface ColumnSpec { /** Output property name on each row object. */ name: Name; /** Cell parser (see `col`). */ parse: ColumnParser; /** * When true, a row missing this (trailing) column is still kept. By default a * row with fewer cells than the number of required columns is dropped. */ optional?: boolean; } /** Flatten an intersection into a single object literal for legible hovers. */ type Simplify = { [K in keyof T]: T[K]; } & {}; /** * The row object inferred from a `const` column-spec tuple. Every non-`null` * column contributes a **required** key (the decoder always assigns it — `null` * when the cell is absent), typed as that column's cell-parser return type. * A `null` spec entry (a skipped position) contributes nothing. */ export type RowOf> = Simplify<{ [S in Extract as S["name"]]: ReturnType; }>; export interface DecodeColumnsOptions { /** Row delimiter (default: any run of whitespace). */ rowSeparator?: string | RegExp; /** Column delimiter within a row (default: `,`). */ colSeparator?: string; } /** * Standard cell parsers. The −999999 sentinel and the literal "NaN" both decode * to `null`. */ export declare const col: { /** Decimal number, or `null` for empty / sentinel / NaN. */ num: (raw: string) => number | null; /** Integer, or `null` for empty / sentinel / NaN. */ int: (raw: string) => number | null; /** Trimmed string, or `null` when empty. */ str: (raw: string) => string | null; /** Boolean, understanding BRO's `ja`/`nee`. */ bool: (raw: string) => boolean | null; }; /** * Decode CSV text into typed row objects per a column spec. * * Rows are split on {@link DecodeColumnsOptions.rowSeparator} (default: * whitespace) and cells on {@link DecodeColumnsOptions.colSeparator} (default: * `,`). Each column is parsed positionally (a missing trailing cell yields * `null`); a `null` entry in `columns` skips that position (for column masks * where only some positions are wanted). A row with fewer cells than the number * of required (non-`optional`, non-skipped) columns is dropped as malformed. */ export declare function decodeColumns(text: string | null | undefined, columns: ReadonlyArray, options?: DecodeColumnsOptions): Array; /** * A {@link Producer} that reads the CSV text at `valuesAt` (relative to the * enclosing node) and decodes it with `decodeColumns`. Yields `[]` when the * values element is absent. * * The row type is **inferred** from the (`as const`) `spec` — each column's name * and cell-parser return type — so callers no longer declare it by hand. */ export declare function columns>(valuesAt: string, spec: Spec, options?: DecodeColumnsOptions): CustomProducer>>; export {}; //# sourceMappingURL=columns.d.ts.map