import type { BatchRecord } from './types.js'; /** Lines of a text file, without their terminators and without the trailing empty one. */ export declare function linesFrom(path: string, encoding?: BufferEncoding): AsyncGenerator; export interface NdjsonOptions { /** Which property holds the text. Default `'text'`. */ textField?: string; /** Which property is the record id. Default `'id'`, if present. */ idField?: string; /** * What to do with a line that is not JSON, or has no text field. * `skip` (default) ignores it, `throw` stops the run at that line. */ onBadLine?: 'skip' | 'throw'; /** * Called for every skipped line. * * Skipping is right for a handful of broken lines in a large export, and wrong * as a silent behaviour when *every* line is skipped — a wrong `textField` * then looks exactly like an empty file. Counting the reasons is what lets a * caller tell those two apart. */ onSkip?: (line: number, reason: 'json' | 'not-object' | 'no-text') => void; } /** One JSON object per line — the format every log pipeline already speaks. */ export declare function ndjsonFrom(path: string, options?: NdjsonOptions): AsyncGenerator; export interface CsvOptions { /** * Column holding the text: a header name, or a zero-based index. * * Omitted, and with a header present, one of the names in `TEXT_COLUMN_NAMES` * is used. If none of them is there and the file has more than one column, * reading **throws** rather than picking the first — scanning the id column and * reporting nothing found is not a result, it only looks like one. */ column?: string | number; /** Column holding the id, if any. */ idColumn?: string | number; /** Field separator. Default `','`. */ delimiter?: string; /** Treat the first row as names. Default true. Required for named columns. */ header?: boolean; /** Called once with the column that ended up being read. */ onColumn?: (chosen: { name?: string; index: number; detected: boolean; }) => void; } /** * Header names that obviously hold the text, tried in this order. * * English and German, because that is what this library ships word lists for. */ export declare const TEXT_COLUMN_NAMES: readonly string[]; /** * Rows of a CSV file, parsed properly. * * A character-level state machine rather than `split('\n')` and `split(',')`, * because a quoted field may contain the delimiter, a newline, or an escaped * quote — and splitting on lines first makes the embedded-newline case * unrecoverable rather than merely wrong. */ export declare function csvRowsFrom(path: string, delimiter?: string): AsyncGenerator; /** Records from one column of a CSV file. */ export declare function csvFrom(path: string, options?: CsvOptions): AsyncGenerator; /** `.ndjson`/`.jsonl` → NDJSON, `.csv`/`.tsv` → CSV, anything else → one text per line. */ export declare function recordsFrom(path: string, options?: NdjsonOptions & CsvOptions): AsyncGenerator | AsyncGenerator; export interface NdjsonWriter { write(value: unknown): Promise; close(): Promise; } /** * Append-as-you-go NDJSON output, respecting backpressure. * * Without the `drain` await, writing a million lines faster than the disk * accepts them buffers the difference in memory — which is the exact failure * the streaming input was there to avoid. */ export declare function createNdjsonWriter(path: string): NdjsonWriter; //# sourceMappingURL=node.d.ts.map