import { parentPort } from "node:worker_threads"; import { createHash } from "node:crypto"; import type { Entry } from "./upsertBatch.ts"; function sha1(value: string): string { return createHash("sha1").update(value).digest("hex").toUpperCase(); } parentPort?.on("message", (lines: string[]) => { const entries: Entry[] = lines.map((line) => { const hash = sha1(line); return { prefix: hash.slice(0, 5), suffix: hash.slice(5), count: 1 }; }); parentPort!.postMessage(entries); });