File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 1
- /// shim for browser packaging
2
1
3
- module . exports = global . WebSocket || global . MozWebSocket ;
2
+ /**
3
+ * Module dependencies.
4
+ */
5
+
6
+ var global = ( function ( ) { return this ; } ) ( ) ;
7
+
8
+ /**
9
+ * WebSocket constructor.
10
+ */
11
+
12
+ var WebSocket = global . WebSocket || global . MozWebSocket ;
13
+
14
+ /**
15
+ * Module exports.
16
+ */
17
+
18
+ module . exports = WebSocket ? ws : null ;
19
+
20
+ /**
21
+ * WebSocket constructor.
22
+ *
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
26
+ *
27
+ * @param {String } uri
28
+ * @param {Array } protocols (optional)
29
+ * @param {Object) opts (optional)
30
+ * @api public
31
+ */
32
+
33
+ function ws ( uri , protocols , opts ) {
34
+ var instance ;
35
+ if ( protocols ) {
36
+ instance = new WebSocket ( uri , protocols ) ;
37
+ } else {
38
+ instance = new WebSocket ( uri ) ;
39
+ }
40
+ return instance ;
41
+ }
42
+
43
+ if ( WebSocket ) ws . prototype = WebSocket . prototype ;
Original file line number Diff line number Diff line change 40
40
"ansi" : " latest"
41
41
},
42
42
"browser" : " ./lib/browser.js" ,
43
+ "component" : {
44
+ "scripts" : {
45
+ "ws/index.js" : " ./lib/browser.js"
46
+ }
47
+ },
43
48
"gypfile" : true
44
49
}
You can’t perform that action at this time.
0 commit comments