Skip to content

Commit

Permalink
fix: dont override methods of created instance (#394)
Browse files Browse the repository at this point in the history
* fix: dont override methods of created instance

* chore: fix lint
  • Loading branch information
jacobheun authored Aug 1, 2019
1 parent f4f3f0f commit 3e95e6f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ class Libp2p extends EventEmitter {
})

this._peerDiscovered = this._peerDiscovered.bind(this)

// promisify all instance methods
;['start', 'stop', 'dial', 'dialProtocol', 'dialFSM', 'hangUp', 'ping'].forEach(method => {
this[method] = promisify(this[method], {
context: this
})
})
}

/**
Expand Down Expand Up @@ -557,6 +550,11 @@ class Libp2p extends EventEmitter {
}
}

// promisify all instance methods
['start', 'stop', 'dial', 'dialProtocol', 'dialFSM', 'hangUp', 'ping'].forEach(method => {
Libp2p[method] = promisify(Libp2p[method])
})

module.exports = Libp2p
/**
* Like `new Libp2p(options)` except it will create a `PeerInfo`
Expand Down

0 comments on commit 3e95e6f

Please sign in to comment.