Skip to content

Commit

Permalink
fix: Remove flat util fn (#136)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node 12+ supported
  • Loading branch information
jimmywarting committed Aug 5, 2021
1 parent 281cd08 commit de7e8a9
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ const stream = require('readable-stream')

const getFiles = require('./get-files') // browser exclude

// TODO: When Node 10 support is dropped, replace this with Array.prototype.flat
function flat (arr1) {
return arr1.reduce(
(acc, val) => Array.isArray(val)
? acc.concat(flat(val))
: acc.concat(val),
[]
)
}

const announceList = [
['udp://tracker.leechers-paradise.org:6969'],
['udp://tracker.coppersurfer.tk:6969'],
Expand Down Expand Up @@ -206,7 +196,7 @@ function _parseInput (input, opts, cb) {
cb(null, file)
}), (err, files) => {
if (err) return cb(err)
files = flat(files)
files = files.flat()
cb(null, files, isSingleFileTorrent)
})
}
Expand Down Expand Up @@ -295,11 +285,11 @@ function onFiles (files, opts, cb) {

if (!announceList) announceList = []

if (global.WEBTORRENT_ANNOUNCE) {
if (typeof global.WEBTORRENT_ANNOUNCE === 'string') {
announceList.push([[global.WEBTORRENT_ANNOUNCE]])
} else if (Array.isArray(global.WEBTORRENT_ANNOUNCE)) {
announceList = announceList.concat(global.WEBTORRENT_ANNOUNCE.map(u => [u]))
if (globalThis.WEBTORRENT_ANNOUNCE) {
if (typeof globalThis.WEBTORRENT_ANNOUNCE === 'string') {
announceList.push([[globalThis.WEBTORRENT_ANNOUNCE]])
} else if (Array.isArray(globalThis.WEBTORRENT_ANNOUNCE)) {
announceList = announceList.concat(globalThis.WEBTORRENT_ANNOUNCE.map(u => [u]))
}
}

Expand Down

0 comments on commit de7e8a9

Please sign in to comment.