fix: dont override methods of created instance (#394)

* fix: dont override methods of created instance

* chore: fix lint
This commit is contained in:
Jacob Heun 2019-08-01 16:08:38 +02:00 committed by GitHub
parent f4f3f0f03a
commit 3e95e6f9e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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`