PeerTube/shared/extra-utils/miscs/webtorrent.ts

17 lines
415 B
TypeScript
Raw Normal View History

2021-07-13 02:43:59 -05:00
import * as WebTorrent from 'webtorrent'
let webtorrent: WebTorrent.Instance
function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
const WebTorrent = require('webtorrent')
if (!webtorrent) webtorrent = new WebTorrent()
if (refreshWebTorrent === true) webtorrent = new WebTorrent()
return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))
}
export {
webtorrentAdd
}