@@ -91,14 +91,14 @@ function Agent(options) {
9191 } else {
9292 // If there are no pending requests, then put it in
9393 // the freeSockets pool, but only if we're allowed to do so.
94- var req = socket . _httpMessage ;
94+ const req = socket . _httpMessage ;
9595 if ( req &&
9696 req . shouldKeepAlive &&
9797 socket . writable &&
9898 this . keepAlive ) {
99- var freeSockets = this . freeSockets [ name ] ;
100- var freeLen = freeSockets ? freeSockets . length : 0 ;
101- var count = freeLen ;
99+ let freeSockets = this . freeSockets [ name ] ;
100+ const freeLen = freeSockets ? freeSockets . length : 0 ;
101+ let count = freeLen ;
102102 if ( this . sockets [ name ] )
103103 count += this . sockets [ name ] . length ;
104104
@@ -130,7 +130,7 @@ Agent.prototype.createConnection = net.createConnection;
130130
131131// Get the key for a given set of request options
132132Agent . prototype . getName = function getName ( options ) {
133- var name = options . host || 'localhost' ;
133+ let name = options . host || 'localhost' ;
134134
135135 name += ':' ;
136136 if ( options . port )
@@ -179,7 +179,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
179179
180180 if ( freeLen ) {
181181 // We have a free socket, so use that.
182- var socket = this . freeSockets [ name ] . shift ( ) ;
182+ const socket = this . freeSockets [ name ] . shift ( ) ;
183183 // Guard against an uninitialized or user supplied Socket.
184184 const handle = socket . _handle ;
185185 if ( handle && typeof handle . asyncReset === 'function' ) {
@@ -222,7 +222,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
222222
223223 debug ( 'createConnection' , name , options ) ;
224224 options . encoding = null ;
225- var called = false ;
225+ let called = false ;
226226
227227 const oncreate = ( err , s ) => {
228228 if ( called )
@@ -308,11 +308,11 @@ Agent.prototype.removeSocket = function removeSocket(s, options) {
308308 if ( ! s . writable )
309309 sets . push ( this . freeSockets ) ;
310310
311- for ( var sk = 0 ; sk < sets . length ; sk ++ ) {
312- var sockets = sets [ sk ] ;
311+ for ( let sk = 0 ; sk < sets . length ; sk ++ ) {
312+ const sockets = sets [ sk ] ;
313313
314314 if ( sockets [ name ] ) {
315- var index = sockets [ name ] . indexOf ( s ) ;
315+ const index = sockets [ name ] . indexOf ( s ) ;
316316 if ( index !== - 1 ) {
317317 sockets [ name ] . splice ( index , 1 ) ;
318318 // Don't leak
@@ -345,12 +345,12 @@ Agent.prototype.reuseSocket = function reuseSocket(socket, req) {
345345
346346Agent . prototype . destroy = function destroy ( ) {
347347 const sets = [ this . freeSockets , this . sockets ] ;
348- for ( var s = 0 ; s < sets . length ; s ++ ) {
349- var set = sets [ s ] ;
350- var keys = Object . keys ( set ) ;
351- for ( var v = 0 ; v < keys . length ; v ++ ) {
352- var setName = set [ keys [ v ] ] ;
353- for ( var n = 0 ; n < setName . length ; n ++ ) {
348+ for ( let s = 0 ; s < sets . length ; s ++ ) {
349+ const set = sets [ s ] ;
350+ const keys = Object . keys ( set ) ;
351+ for ( let v = 0 ; v < keys . length ; v ++ ) {
352+ const setName = set [ keys [ v ] ] ;
353+ for ( let n = 0 ; n < setName . length ; n ++ ) {
354354 setName [ n ] . destroy ( ) ;
355355 }
356356 }
0 commit comments