mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-16 13:55:51 -07:00
20 lines
606 B
TypeScript
20 lines
606 B
TypeScript
import { parentPort, workerData } from 'node:worker_threads';
|
|
import { executeVocabularySummaryTask } from './vocabulary-summary-worker';
|
|
|
|
interface VocabularySummaryWorkerData {
|
|
dbPath: string;
|
|
knownWords: string[] | null;
|
|
}
|
|
|
|
if (!parentPort) throw new Error('vocabulary summary worker missing parent port');
|
|
|
|
const request = workerData as VocabularySummaryWorkerData;
|
|
|
|
try {
|
|
parentPort.postMessage({
|
|
summary: executeVocabularySummaryTask(request.dbPath, request.knownWords),
|
|
});
|
|
} catch (error) {
|
|
parentPort.postMessage({ error: error instanceof Error ? error.message : String(error) });
|
|
}
|