@@ -74,19 +74,6 @@ class WebSocket extends EventEmitter {
74
74
}
75
75
}
76
76
77
- get CONNECTING ( ) {
78
- return WebSocket . CONNECTING ;
79
- }
80
- get CLOSING ( ) {
81
- return WebSocket . CLOSING ;
82
- }
83
- get CLOSED ( ) {
84
- return WebSocket . CLOSED ;
85
- }
86
- get OPEN ( ) {
87
- return WebSocket . OPEN ;
88
- }
89
-
90
77
/**
91
78
* This deviates from the WHATWG interface since ws doesn't support the
92
79
* required default "blob" type (instead we define a custom "nodebuffer"
@@ -394,10 +381,21 @@ class WebSocket extends EventEmitter {
394
381
}
395
382
396
383
readyStates . forEach ( ( readyState , i ) => {
397
- Object . defineProperty ( WebSocket , readyState , {
398
- enumerable : true ,
399
- value : i
400
- } ) ;
384
+ const descriptor = { enumerable : true , value : i } ;
385
+
386
+ Object . defineProperty ( WebSocket . prototype , readyState , descriptor ) ;
387
+ Object . defineProperty ( WebSocket , readyState , descriptor ) ;
388
+ } ) ;
389
+
390
+ [
391
+ 'binaryType' ,
392
+ 'bufferedAmount' ,
393
+ 'extensions' ,
394
+ 'protocol' ,
395
+ 'readyState' ,
396
+ 'url'
397
+ ] . forEach ( ( property ) => {
398
+ Object . defineProperty ( WebSocket . prototype , property , { enumerable : true } ) ;
401
399
} ) ;
402
400
403
401
//
@@ -406,6 +404,8 @@ readyStates.forEach((readyState, i) => {
406
404
//
407
405
[ 'open' , 'error' , 'close' , 'message' ] . forEach ( ( method ) => {
408
406
Object . defineProperty ( WebSocket . prototype , `on${ method } ` , {
407
+ configurable : true ,
408
+ enumerable : true ,
409
409
/**
410
410
* Return the listener of the event.
411
411
*
0 commit comments