@@ -12,22 +12,24 @@ export interface SendOptions {
1212 compress ?: boolean ;
1313}
1414
15+ type ReadyState = "opening" | "open" | "closing" | "closed" ;
16+
1517export class Socket extends EventEmitter {
1618 public readonly protocol : number ;
1719 // TODO for the next major release: do not keep the reference to the first HTTP request, as it stays in memory
1820 public readonly request : IncomingMessage ;
1921 public readonly remoteAddress : string ;
2022
21- public _readyState : string ;
23+ public _readyState : ReadyState = "opening" ;
2224 public transport : Transport ;
2325
2426 private server : Server ;
25- private upgrading : boolean ;
26- private upgraded : boolean ;
27- private writeBuffer : Packet [ ] ;
28- private packetsFn : Array < ( ) => void > ;
29- private sentCallbackFn : any [ ] ;
30- private cleanupFn : any [ ] ;
27+ private upgrading = false ;
28+ private upgraded = false ;
29+ private writeBuffer : Packet [ ] = [ ] ;
30+ private packetsFn : Array < ( ) => void > = [ ] ;
31+ private sentCallbackFn : any [ ] = [ ] ;
32+ private cleanupFn : any [ ] = [ ] ;
3133 private pingTimeoutTimer ;
3234 private pingIntervalTimer ;
3335
@@ -43,7 +45,7 @@ export class Socket extends EventEmitter {
4345 return this . _readyState ;
4446 }
4547
46- set readyState ( state ) {
48+ set readyState ( state : ReadyState ) {
4749 debug ( "readyState updated from %s to %s" , this . _readyState , state ) ;
4850 this . _readyState = state ;
4951 }
@@ -57,13 +59,6 @@ export class Socket extends EventEmitter {
5759 super ( ) ;
5860 this . id = id ;
5961 this . server = server ;
60- this . upgrading = false ;
61- this . upgraded = false ;
62- this . readyState = "opening" ;
63- this . writeBuffer = [ ] ;
64- this . packetsFn = [ ] ;
65- this . sentCallbackFn = [ ] ;
66- this . cleanupFn = [ ] ;
6762 this . request = req ;
6863 this . protocol = protocol ;
6964
@@ -179,7 +174,7 @@ export class Socket extends EventEmitter {
179174 /**
180175 * Called upon transport error.
181176 *
182- * @param {Error } error object
177+ * @param {Error } err - error object
183178 * @api private
184179 */
185180 private onError ( err ) {
0 commit comments