6 var global = (function() { return this; })();
9 * WebSocket constructor.
12 var WebSocket = global.WebSocket || global.MozWebSocket;
18 module.exports = WebSocket ? ws : null;
21 * WebSocket constructor.
23 * The third `opts` options object gets ignored in web browsers, since it's
24 * non-standard, and throws a TypeError if passed to the constructor.
25 * See: https://github.com/einaros/ws/issues/227
28 * @param {Array} protocols (optional)
29 * @param {Object) opts (optional)
33 function ws(uri, protocols, opts) {
36 instance = new WebSocket(uri, protocols);
38 instance = new WebSocket(uri);
43 if (WebSocket) ws.prototype = WebSocket.prototype;