Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: esm #87

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const debug = require('debug')('torrent-discovery')
const DHT = require('bittorrent-dht/client') // empty object in browser
const EventEmitter = require('events').EventEmitter
const parallel = require('run-parallel')
const Tracker = require('bittorrent-tracker/client')
const LSD = require('bittorrent-lsd')
import Debug from 'debug'
import DHT from 'bittorrent-dht/client.js' // empty object in browser
import { EventEmitter } from 'events'
import parallel from 'run-parallel'
import Tracker from 'bittorrent-tracker/client.js'
import LSD from 'bittorrent-lsd'

const debug = Debug('torrent-discovery')

class Discovery extends EventEmitter {
constructor (opts) {
Expand Down Expand Up @@ -219,4 +221,4 @@ class Discovery extends EventEmitter {
}
}

module.exports = Discovery
export default Discovery
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"url": "https://webtorrent.io"
},
"browser": {
"bittorrent-dht/client": false,
"bittorrent-dht/client.js": false,
"bittorrent-lsd": false
},
"chromeapp": {},
"bugs": {
"url": "https://github.com/webtorrent/torrent-discovery/issues"
},
"type": "module",
"dependencies": {
"bittorrent-dht": "^10.0.6",
"bittorrent-tracker": "^9.19.0",
Expand Down Expand Up @@ -44,7 +45,12 @@
"peer discovery"
],
"license": "MIT",
"main": "index.js",
"engines": {
"node": ">=12.20.0"
},
"exports": {
"import": "./index.js"
},
"repository": {
"type": "git",
"url": "git://github.com/webtorrent/torrent-discovery.git"
Expand Down
8 changes: 4 additions & 4 deletions test/announce.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const DHT = require('bittorrent-dht')
const Discovery = require('../')
const randombytes = require('randombytes')
const test = require('tape')
import DHT from 'bittorrent-dht'
import Discovery from '../index.js'
import randombytes from 'randombytes'
import test from 'tape'

test('initialize with dht', t => {
t.plan(5)
Expand Down
8 changes: 4 additions & 4 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discovery = require('../')
const DHT = require('bittorrent-dht')
const randombytes = require('randombytes')
const test = require('tape')
import Discovery from '../index.js'
import DHT from 'bittorrent-dht'
import randombytes from 'randombytes'
import test from 'tape'

test('initialize with dht', t => {
t.plan(1)
Expand Down
8 changes: 4 additions & 4 deletions test/reuse-dht.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discovery = require('../')
const DHT = require('bittorrent-dht')
const randombytes = require('randombytes')
const test = require('tape')
import Discovery from '../index.js'
import DHT from 'bittorrent-dht'
import randombytes from 'randombytes'
import test from 'tape'

test('re-use dht, verify that peers are filtered', t => {
t.plan(5)
Expand Down