mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
14 lines
346 B
TypeScript
14 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);
|
|
}
|
|
});
|