feat: use class-is for type checks

This commit is contained in:
Diogo Silva 2018-04-03 15:51:05 +01:00 committed by David Dias
parent 141920cd14
commit bb0c9905ed

View File

@ -10,6 +10,7 @@ const series = require('async/series')
const PeerBook = require('peer-book') const PeerBook = require('peer-book')
const Switch = require('libp2p-switch') const Switch = require('libp2p-switch')
const Ping = require('libp2p-ping') const Ping = require('libp2p-ping')
const WebSockets = require('libp2p-websockets')
const peerRouting = require('./peer-routing') const peerRouting = require('./peer-routing')
const contentRouting = require('./content-routing') const contentRouting = require('./content-routing')
@ -129,8 +130,7 @@ class Node extends EventEmitter {
if (transport.filter(multiaddrs).length > 0) { if (transport.filter(multiaddrs).length > 0) {
this.switch.transport.add( this.switch.transport.add(
transport.tag || transport.constructor.name, transport) transport.tag || transport.constructor.name, transport)
} else if (transport.constructor && } else if (WebSockets.isWebSockets(transport)) {
transport.constructor.name === 'WebSockets') {
// TODO find a cleaner way to signal that a transport is always // TODO find a cleaner way to signal that a transport is always
// used for dialing, even if no listener // used for dialing, even if no listener
ws = transport ws = transport