@@ -95,14 +95,14 @@ function Agent(options) {
9595 } else {
9696 // If there are no pending requests, then put it in
9797 // the freeSockets pool, but only if we're allowed to do so.
98- var req = socket . _httpMessage ;
98+ const req = socket . _httpMessage ;
9999 if ( req &&
100100 req . shouldKeepAlive &&
101101 socket . writable &&
102102 this . keepAlive ) {
103- var freeSockets = this . freeSockets [ name ] ;
104- var freeLen = freeSockets ? freeSockets . length : 0 ;
105- var count = freeLen ;
103+ let freeSockets = this . freeSockets [ name ] ;
104+ const freeLen = freeSockets ? freeSockets . length : 0 ;
105+ let count = freeLen ;
106106 if ( this . sockets [ name ] )
107107 count += this . sockets [ name ] . length ;
108108
@@ -134,7 +134,7 @@ Agent.prototype.createConnection = net.createConnection;
134134
135135// Get the key for a given set of request options
136136Agent . prototype . getName = function getName ( options ) {
137- var name = options . host || 'localhost' ;
137+ let name = options . host || 'localhost' ;
138138
139139 name += ':' ;
140140 if ( options . port )
@@ -183,7 +183,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
183183
184184 if ( freeLen ) {
185185 // We have a free socket, so use that.
186- var socket = this . freeSockets [ name ] . shift ( ) ;
186+ const socket = this . freeSockets [ name ] . shift ( ) ;
187187 // Guard against an uninitialized or user supplied Socket.
188188 const handle = socket . _handle ;
189189 if ( handle && typeof handle . asyncReset === 'function' ) {
@@ -226,7 +226,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
226226
227227 debug ( 'createConnection' , name , options ) ;
228228 options . encoding = null ;
229- var called = false ;
229+ let called = false ;
230230
231231 const oncreate = ( err , s ) => {
232232 if ( called )
@@ -317,11 +317,11 @@ Agent.prototype.removeSocket = function removeSocket(s, options) {
317317 if ( ! s . writable )
318318 sets . push ( this . freeSockets ) ;
319319
320- for ( var sk = 0 ; sk < sets . length ; sk ++ ) {
321- var sockets = sets [ sk ] ;
320+ for ( let sk = 0 ; sk < sets . length ; sk ++ ) {
321+ const sockets = sets [ sk ] ;
322322
323323 if ( sockets [ name ] ) {
324- var index = sockets [ name ] . indexOf ( s ) ;
324+ const index = sockets [ name ] . indexOf ( s ) ;
325325 if ( index !== - 1 ) {
326326 sockets [ name ] . splice ( index , 1 ) ;
327327 // Don't leak
@@ -355,12 +355,12 @@ Agent.prototype.reuseSocket = function reuseSocket(socket, req) {
355355
356356Agent . prototype . destroy = function destroy ( ) {
357357 const sets = [ this . freeSockets , this . sockets ] ;
358- for ( var s = 0 ; s < sets . length ; s ++ ) {
359- var set = sets [ s ] ;
360- var keys = Object . keys ( set ) ;
361- for ( var v = 0 ; v < keys . length ; v ++ ) {
362- var setName = set [ keys [ v ] ] ;
363- for ( var n = 0 ; n < setName . length ; n ++ ) {
358+ for ( let s = 0 ; s < sets . length ; s ++ ) {
359+ const set = sets [ s ] ;
360+ const keys = Object . keys ( set ) ;
361+ for ( let v = 0 ; v < keys . length ; v ++ ) {
362+ const setName = set [ keys [ v ] ] ;
363+ for ( let n = 0 ; n < setName . length ; n ++ ) {
364364 setName [ n ] . destroy ( ) ;
365365 }
366366 }
0 commit comments