From 3e95e6f9e4affc2c89961cdf621624c44865aebd Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Thu, 1 Aug 2019 16:08:38 +0200 Subject: [PATCH] fix: dont override methods of created instance (#394) * fix: dont override methods of created instance * chore: fix lint --- src/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 5be1f7b77a..f76e8fd6ba 100644 --- a/src/index.js +++ b/src/index.js @@ -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 - }) - }) } /** @@ -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`