@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
27 lines (26 loc) • 1.46 kB
TypeScript
/**
* Shared, RFC-4180-aware delimiter-separated-value helpers.
*
* Consolidates quote-aware field counting/splitting that was previously
* duplicated across csvProcessor.ts and fileDetector.ts (#359), and adds
* delimiter detection so TSV / semicolon / pipe files parse correctly (#361).
* Keeping these in one module prevents the same quoting edge case from having
* to be fixed in three places and drifting out of sync.
*/
/** Delimiter candidates, in tie-break preference order (comma first). */
export declare const CANDIDATE_DELIMITERS: readonly [",", "\t", ";", "|"];
/**
* Split a single line into fields, respecting RFC-4180 quoting: a delimiter
* inside a `"…"` quoted field does not split, and `""` is an escaped quote.
*/
export declare function splitCSVFields(line: string, delimiter?: string): string[];
/** Count fields in a single line, respecting RFC-4180 quoting. */
export declare function countCSVColumns(line: string, delimiter?: string): number;
/**
* Detect the delimiter of DSV content by testing comma/tab/semicolon/pipe
* against up to 5 sampled non-empty lines and keeping the candidate with the
* most consistent (>1) column count. Comma wins ties and the "nothing splits"
* case, so plain CSVs are never reclassified. An optional extension hint
* (`tsv` → tab, `psv` → pipe) breaks ambiguity in the file's favor.
*/
export declare function detectDelimiter(lines: string[], extensionHint?: string): string;