aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/miscs
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r--shared/extra-utils/miscs/miscs.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts
index fb6430e4f..42250886c 100644
--- a/shared/extra-utils/miscs/miscs.ts
+++ b/shared/extra-utils/miscs/miscs.ts
@@ -8,7 +8,7 @@ import { pathExists, readFile } from 'fs-extra'
8import * as ffmpeg from 'fluent-ffmpeg' 8import * as ffmpeg from 'fluent-ffmpeg'
9 9
10const expect = chai.expect 10const expect = chai.expect
11let webtorrent = new WebTorrent() 11let webtorrent: WebTorrent.Instance
12 12
13function immutableAssign <T, U> (target: T, source: U) { 13function immutableAssign <T, U> (target: T, source: U) {
14 return Object.assign<{}, T, U>({}, target, source) 14 return Object.assign<{}, T, U>({}, target, source)
@@ -27,6 +27,9 @@ function wait (milliseconds: number) {
27} 27}
28 28
29function webtorrentAdd (torrent: string, refreshWebTorrent = false) { 29function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
30 const WebTorrent = require('webtorrent')
31
32 if (!webtorrent) webtorrent = new WebTorrent()
30 if (refreshWebTorrent === true) webtorrent = new WebTorrent() 33 if (refreshWebTorrent === true) webtorrent = new WebTorrent()
31 34
32 return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) 35 return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))