In Peer constructor port, network and relay is optional arguments. When port is Object and network isn't undefined arguments will be overloaded, but only port and network, not relay.
i.e. instead
// overloading stuff
if (port instanceof Object && !network) {
network = port;
port = undefined;
}
should be something like this
var test = Function.prototype.call.bind(Object.prototype.toString)
---
if (test(network) === '[object Boolean]' && !relay) {
relay = network
network = undefined
if (test(port) === '[object Object]') {
network = port
port = undefined
}
}
if (test(port) === '[object Object]' && !network && !relay) {
network = port
port = relay = undefined
}
if (test(port) === '[object Boolean]' && !network && !relay) {
relay = network
port = network = undefined
}
I'm right?
Of course it's not simple overloading, so it may be better to use opts as in Pool?
In
Peer
constructorport
,network
andrelay
is optional arguments. Whenport
isObject
andnetwork
isn'tundefined
arguments will be overloaded, but onlyport
andnetwork
, notrelay
.i.e. instead
should be something like this
I'm right? Of course it's not simple overloading, so it may be better to use
opts
as inPool
?Also
@param
missing forrelay
.