Set default options more robustly

This commit is contained in:
d3x0r
2016-12-21 12:17:01 -08:00
committed by GitHub
parent f28b62fd4c
commit 320183fa54

View File

@@ -83,7 +83,8 @@ function Peer (url, options) {
this.setMaxListeners(Infinity);
this.options = options || {};
this.options.wsc = options.wsc || { protocols: null };
if( !('wsc" in this.options ) ) this.options.wsc = options.wsc || { protocols: null };
else if( !("protocols" in this.options.wsc) ) this.options.wsc.protocols = null;
// Messages sent before the socket is ready.
this.deferredMsgs = [];