@@ -15,16 +15,6 @@ const stream = require('readable-stream')
1515
1616const getFiles = require ( './get-files' ) // browser exclude
1717
18- // TODO: When Node 10 support is dropped, replace this with Array.prototype.flat
19- function flat ( arr1 ) {
20- return arr1 . reduce (
21- ( acc , val ) => Array . isArray ( val )
22- ? acc . concat ( flat ( val ) )
23- : acc . concat ( val ) ,
24- [ ]
25- )
26- }
27-
2818const announceList = [
2919 [ 'udp://tracker.leechers-paradise.org:6969' ] ,
3020 [ 'udp://tracker.coppersurfer.tk:6969' ] ,
@@ -206,7 +196,7 @@ function _parseInput (input, opts, cb) {
206196 cb ( null , file )
207197 } ) , ( err , files ) => {
208198 if ( err ) return cb ( err )
209- files = flat ( files )
199+ files = files . flat ( )
210200 cb ( null , files , isSingleFileTorrent )
211201 } )
212202 }
@@ -295,11 +285,11 @@ function onFiles (files, opts, cb) {
295285
296286 if ( ! announceList ) announceList = [ ]
297287
298- if ( global . WEBTORRENT_ANNOUNCE ) {
299- if ( typeof global . WEBTORRENT_ANNOUNCE === 'string' ) {
300- announceList . push ( [ [ global . WEBTORRENT_ANNOUNCE ] ] )
301- } else if ( Array . isArray ( global . WEBTORRENT_ANNOUNCE ) ) {
302- announceList = announceList . concat ( global . WEBTORRENT_ANNOUNCE . map ( u => [ u ] ) )
288+ if ( globalThis . WEBTORRENT_ANNOUNCE ) {
289+ if ( typeof globalThis . WEBTORRENT_ANNOUNCE === 'string' ) {
290+ announceList . push ( [ [ globalThis . WEBTORRENT_ANNOUNCE ] ] )
291+ } else if ( Array . isArray ( globalThis . WEBTORRENT_ANNOUNCE ) ) {
292+ announceList = announceList . concat ( globalThis . WEBTORRENT_ANNOUNCE . map ( u => [ u ] ) )
303293 }
304294 }
305295
0 commit comments