11/*! create-torrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
2- const bencode = require ( 'bencode' )
3- const blockIterator = require ( 'block-iterator' )
4- const calcPieceLength = require ( 'piece-length' )
5- const corePath = require ( 'path' )
6- const isFile = require ( 'is-file' )
7- const junk = require ( 'junk' )
8- const joinIterator = require ( 'join-async-iterator' )
9- const parallel = require ( 'run-parallel' )
10- const queueMicrotask = require ( 'queue-microtask' )
11- const sha1 = require ( 'simple-sha1' )
12- require ( 'fast-readable-async-iterator' )
13-
14- const getFiles = require ( './get-files' ) // browser exclude
2+ import bencode from 'bencode'
3+ import blockIterator from 'block-iterator'
4+ import calcPieceLength from 'piece-length'
5+ import corePath from 'path'
6+ import isFile from 'is-file'
7+ import junk from 'junk'
8+ import joinIterator from 'join-async-iterator'
9+ import parallel from 'run-parallel'
10+ import queueMicrotask from 'queue-microtask'
11+ import sha1 from 'simple-sha1'
12+ import 'fast-readable-async-iterator'
13+
14+ import getFiles from './get-files.js' // browser exclude
1515
1616const announceList = [
1717 [ 'udp://tracker.leechers-paradise.org:6969' ] ,
@@ -243,28 +243,28 @@ async function getPieceList (files, pieceLength, estimatedTorrentLength, opts, c
243243}
244244
245245function onFiles ( files , opts , cb ) {
246- let announceList = opts . announceList
246+ let _announceList = opts . announceList
247247
248- if ( ! announceList ) {
249- if ( typeof opts . announce === 'string' ) announceList = [ [ opts . announce ] ]
248+ if ( ! _announceList ) {
249+ if ( typeof opts . announce === 'string' ) _announceList = [ [ opts . announce ] ]
250250 else if ( Array . isArray ( opts . announce ) ) {
251- announceList = opts . announce . map ( u => [ u ] )
251+ _announceList = opts . announce . map ( u => [ u ] )
252252 }
253253 }
254254
255- if ( ! announceList ) announceList = [ ]
255+ if ( ! _announceList ) _announceList = [ ]
256256
257257 if ( globalThis . WEBTORRENT_ANNOUNCE ) {
258258 if ( typeof globalThis . WEBTORRENT_ANNOUNCE === 'string' ) {
259- announceList . push ( [ [ globalThis . WEBTORRENT_ANNOUNCE ] ] )
259+ _announceList . push ( [ [ globalThis . WEBTORRENT_ANNOUNCE ] ] )
260260 } else if ( Array . isArray ( globalThis . WEBTORRENT_ANNOUNCE ) ) {
261- announceList = announceList . concat ( globalThis . WEBTORRENT_ANNOUNCE . map ( u => [ u ] ) )
261+ _announceList = _announceList . concat ( globalThis . WEBTORRENT_ANNOUNCE . map ( u => [ u ] ) )
262262 }
263263 }
264264
265265 // When no trackers specified, use some reasonable defaults
266266 if ( opts . announce === undefined && opts . announceList === undefined ) {
267- announceList = announceList . concat ( module . exports . announceList )
267+ _announceList = _announceList . concat ( announceList )
268268 }
269269
270270 if ( typeof opts . urlList === 'string' ) opts . urlList = [ opts . urlList ]
@@ -277,9 +277,9 @@ function onFiles (files, opts, cb) {
277277 encoding : 'UTF-8'
278278 }
279279
280- if ( announceList . length !== 0 ) {
281- torrent . announce = announceList [ 0 ] [ 0 ]
282- torrent [ 'announce-list' ] = announceList
280+ if ( _announceList . length !== 0 ) {
281+ torrent . announce = _announceList [ 0 ] [ 0 ]
282+ torrent [ 'announce-list' ] = _announceList
283283 }
284284
285285 if ( opts . comment !== undefined ) torrent . comment = opts . comment
@@ -391,7 +391,5 @@ async function * getStreamStream (readable, file) {
391391 }
392392}
393393
394- module . exports = createTorrent
395- module . exports . parseInput = parseInput
396- module . exports . announceList = announceList
397- module . exports . isJunkPath = isJunkPath
394+ export default createTorrent
395+ export { parseInput , announceList , isJunkPath }
0 commit comments