src/utils/torrent.js
function getDataTorrentFromFile(torrentFile) {
  if(!fs.existsSync(torrentFile)) {
    throw new Error(`This torrent file does not exists : ${torrentFile}`);
  }

  const torrent = parseTorrent(fs.readFileSync(torrentFile));
  torrent.path = torrentFile;
  torrent.hash = torrent.infoHash.toUpperCase();
  return torrent;
}
function getDataTorrentFromFile(torrentFile) {
  if(!fs.existsSync(torrentFile)) {
    throw new Error(`This torrent file does not exists : ${torrentFile}`);
  }

  const torrent = parseTorrent(fs.readFileSync(torrentFile));
  torrent.path = torrentFile;
  torrent.hash = torrent.infoHash.toUpperCase();
  return torrent;
}
function getDataTorrentFromFile ( torrentFile ) { if ( ! fs . existsSync ( torrentFile ) ) { throw new Error ( ` ${ torrentFile } ` ) ; } const torrent = parseTorrent ( fs . readFileSync ( torrentFile ) ) ; torrent . path = torrentFile ; torrent . hash = torrent . infoHash . toUpperCase ( ) ; return torrent ; }
Read torrent content then return result
@param torrentFile
@return {Object}
Read torrent content then return result