Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

feat: bump aegir and add types #111

Merged
merged 4 commits into from
Feb 8, 2021
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"node": ">=6.0.0",
"npm": ">=3.0.0"
},
"types": "dist/src/index.d.ts",
"devDependencies": {
"aegir": "^25.0.0",
"@types/debug": "^4.1.5",
"aegir": "^30.3.0",
"libp2p-interfaces": "^0.4.0"
},
"dependencies": {
Expand Down
13 changes: 7 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const mafmt = require('mafmt')
const { EventEmitter } = require('events')
const debug = require('debug')

const log = debug('libp2p:bootstrap')
log.error = debug('libp2p:bootstrap:error')
const log = Object.assign(debug('libp2p:bootstrap'), {
error: debug('libp2p:bootstrap:error')
})

/**
* Emits 'peer' events on a regular interval for each peer in the provided list.
Expand All @@ -18,10 +19,10 @@ class Bootstrap extends EventEmitter {
*
* @param {Object} options
* @param {Array<string>} options.list - the list of peer addresses in multi-address format
* @param {number} [options.interval] - the interval between emitting addresses in milliseconds (default: 10000)
* @param {number} [options.interval = 10000] - the interval between emitting addresses in milliseconds
*
*/
constructor (options = {}) {
constructor (options = { list: [] }) {
if (!options.list || !options.list.length) {
throw new Error('Bootstrap requires a list of peer addresses')
}
Expand All @@ -41,7 +42,7 @@ class Bootstrap extends EventEmitter {
}

this._timer = setInterval(() => this._discoverBootstrapPeers(), this._interval)

log('Starting bootstrap node discovery')
this._discoverBootstrapPeers()
}

Expand Down Expand Up @@ -77,7 +78,7 @@ class Bootstrap extends EventEmitter {
* Stop emitting events.
*/
stop () {
clearInterval(this._timer)
if (this._timer) clearInterval(this._timer)
this._timer = null
}
}
Expand Down
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"baseUrl": "./",
"paths": {
"*": ["./types/*"]
}
},
"include": [
"types",
"test", // remove this line if you don't want to type-check tests
"src"
]
}