UNPKG

noqq

Version:

No query query data chat for fraction of normal cost

14 lines (13 loc) 504 B
import { parentPort, workerData } from "worker_threads"; import fs from "fs"; const { parse } = await import("fast-csv"); if (!parentPort) { throw new Error("This script must be run as a worker."); } const { filePath } = workerData; const results = []; fs.createReadStream(filePath) .pipe(parse({ headers: true, ignoreEmpty: true })) .on("data", (row) => results.push(row)) .on("end", () => parentPort.postMessage(results)) .on("error", (error) => parentPort.postMessage({ error }));