Skip to content

Commit

Permalink
feat: esm (#30)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ESM only
* feat: esm

* Update index.js

Co-authored-by: Diego Rodríguez Baquero <[email protected]>

Co-authored-by: Diego Rodríguez Baquero <[email protected]>
BREAKING CHANGE: ESM only
  • Loading branch information
ThaUnknown authored Dec 5, 2022
1 parent a41bfbb commit 4f45f6f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*! bittorrent-lsd. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const dgram = require('dgram')
const EventEmitter = require('events').EventEmitter
const debug = require('debug')('bittorrent-lsd')
import dgram from 'dgram'
import { EventEmitter } from 'events'
import Debug from 'debug'

const debug = Debug('bittorrent-lsd')

const ANNOUNCE_INTERVAL = 300000 // 5min
const LSD_HOST = '239.192.152.143'
Expand Down Expand Up @@ -154,4 +156,4 @@ class LSD extends EventEmitter {
}
}

module.exports = LSD
export default LSD
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"bugs": {
"url": "https://github.com/webtorrent/bittorrent-lsd/issues"
},
"type": "module",
"dependencies": {
"chrome-dgram": "^3.0.6",
"debug": "^4.2.0"
Expand Down Expand Up @@ -55,8 +56,13 @@
"peer-to-peer",
"webtorrent"
],
"engines": {
"node": ">=12.20.0"
},
"exports": {
"import": "./index.js"
},
"license": "MIT",
"main": "index.js",
"release": {
"extends": "@webtorrent/semantic-release-config"
},
Expand Down
6 changes: 3 additions & 3 deletions test/announce.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const test = require('tape')
const common = require('./common')
import test from 'tape'
import * as common from './common.js'

const LSD = require('../index')
import LSD from '../index.js'

test('should emit a warning when invalid announce header', t => {
const opts = {
Expand Down
12 changes: 6 additions & 6 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const test = require('tape')
const sinon = require('sinon')
const dgram = require('dgram')
const os = require('os')
const common = require('./common')
import test from 'tape'
import sinon from 'sinon'
import dgram from 'dgram'
import os from 'os'
import * as common from './common.js'

const LSD = require('../index')
import LSD from '../index.js'

test('should emit a warning when addMembership fails', t => {
const opts = {
Expand Down
8 changes: 4 additions & 4 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const crypto = require('crypto')
import crypto from 'crypto'

exports.randomPort = () => {
export const randomPort = () => {
return crypto.randomBytes(2).readUInt16LE(0)
}

exports.randomId = () => {
export const randomId = () => {
return crypto.randomBytes(20)
}

exports.randomHash = () => {
export const randomHash = () => {
return crypto.randomBytes(20)
}

0 comments on commit 4f45f6f

Please sign in to comment.