Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer arguments overloading #46

Closed
fanatid opened this issue Mar 5, 2015 · 3 comments
Closed

Peer arguments overloading #46

fanatid opened this issue Mar 5, 2015 · 3 comments

Comments

@fanatid
Copy link
Contributor

fanatid commented Mar 5, 2015

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?

Also @param missing for relay.

@maraoz
Copy link
Contributor

maraoz commented Mar 5, 2015

+1
I think we should use an opts object probably

@braydonf
Copy link
Contributor

braydonf commented Mar 6, 2015

Agree with the options object.

@braydonf
Copy link
Contributor

Options object for params included in: #48

@fanatid fanatid closed this as completed Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants