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`