mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 22:06:17 +00:00
15 lines
346 B
TypeScript
15 lines
346 B
TypeScript
import { parentPort } from "worker_threads";
|
|
import parseTorrent from "parse-torrent";
|
|
|
|
const port = parentPort;
|
|
if (!port) throw new Error("IllegalState");
|
|
|
|
port.on("message", async (buffer: Buffer) => {
|
|
try {
|
|
const torrent = await parseTorrent(buffer);
|
|
port.postMessage(torrent);
|
|
} catch (err) {
|
|
port.postMessage(null);
|
|
}
|
|
});
|