1
0
Fork 0
peertube/shared/extra-utils/miscs/webtorrent.ts

17 lines
415 B
TypeScript
Raw Normal View History

2021-07-13 07:43:59 +00: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
}