webtorrent/parse-torrent

await ParseTorrent

damienmillet opened this issue · 1 comments

What version of this package are you using?
11.0.16
What operating system, Node.js, and npm version?
MacOs, NodeJs v22.2.0 with NextJS 14.2.3, npm 10.7.0
What happened?
ParseTorrent isn't typed as promise but work only with the await keyword
What did you expect to happen?

this is an example, maybe I'm wrong

    const fileBlob = await file.arrayBuffer();
    const fileBuffer = Buffer.from(fileBlob);
    const fileName = file.name;
    const torrent = ParseTorrent(fileBuffer);
    const magnet = toMagnetURI(torrent);
    // return only "magnet:?"
    const torrent = await ParseTorrent(fileBuffer); // but isn't typed as Promise
    const magnet = toMagnetURI(torrent);
    // return a correct magnet link

Are you willing to submit a pull request to fix this bug?
no

webtorrent and parsetorrent doesn't provide types, you're likely using some 3rd party library for types which is incorrect