/** * worker.ts — Worker Thread code for csv-super Pro multi-threading. * * This file runs in a SEPARATE thread context — it cannot access * variables, imports, or state from the main thread. * * Communication protocol: * Main → Worker: WorkerTask (via postMessage) * Worker → Main: WorkerMessage (batch | done | error) * * Each worker receives a byte range [start, end] of the CSV file * and parses its portion independently. * * Boundary handling: * - The first worker starts at byte 0 (includes the header row). * - Workers 2..N start at their assigned byte, then skip forward * to the next complete line to avoid splitting a row mid-way. * - The header is parsed once by worker 0 and broadcast to others. */ import type { BatchResult } from '../types/index.js'; export interface WorkerTask { taskId: number; start: number; end: number; batchSize: number; headers: string[] | null; } export type WorkerMessage = { type: 'batch'; taskId: number; batch: BatchResult; } | { type: 'done'; taskId: number; totalRows: number; } | { type: 'error'; taskId: number; message: string; stack?: string; } | { type: 'header'; taskId: number; headers: string[]; }; //# sourceMappingURL=worker.d.ts.map