@@ -229,18 +229,18 @@ exports.initCommands = function (proto) {
229229 proto . clientCommands = commands
230230
231231 proto . clientCalcSlot = function ( reqArray ) {
232- let info = commandsInfo [ reqArray [ 0 ] ]
232+ const info = commandsInfo [ reqArray [ 0 ] ]
233233 if ( ! info || reqArray . length === 1 || ( info [ 2 ] === 0 && info [ 0 ] !== 1 ) ) return null
234234 // if command have no argument but user provide one, use the argument to calcSlot
235235 // it is useful in cluster for `multi`, `exec`, `discard`, `unwatch` and so on
236- let keyIndex = info [ 2 ] || 1
236+ const keyIndex = info [ 2 ] || 1
237237 // Only calc first key, user should ensure that all keys are in a same node.
238- let slot = calcSlot ( reqArray [ keyIndex ] )
238+ const slot = calcSlot ( reqArray [ keyIndex ] )
239239 if ( info [ 0 ] === 1 ) reqArray . length = 1
240240 return slot
241241 }
242242
243- for ( let command of commands ) {
243+ for ( const command of commands ) {
244244 proto [ command ] = function ( ) {
245245 return sendCommand ( this , command , adjustArgs ( arguments ) )
246246 }
@@ -282,23 +282,23 @@ exports.initCommands = function (proto) {
282282 }
283283
284284 proto . pubsub = function ( ) {
285- let args = adjustArgs ( arguments )
285+ const args = adjustArgs ( arguments )
286286 return sendCommand ( this , 'pubsub' , args , 0 , function ( res ) {
287287 if ( args [ 0 ] . toLowerCase ( ) === 'numsub' ) res = toHash ( res )
288288 return res
289289 } )
290290 }
291291
292292 proto . monitor = function ( hashKey ) {
293- let args = adjustArgs ( arguments )
293+ const args = adjustArgs ( arguments )
294294 if ( hashKey || ! this . _redisState . clusterMode ) {
295295 return sendCommand ( this , 'monitor' , args )
296296 }
297297
298298 // monit all nodes in cluster mode
299- let tasks = [ ]
300- for ( let key of Object . keys ( this . _redisState . pool ) ) {
301- let connection = this . _redisState . pool [ key ]
299+ const tasks = [ ]
300+ for ( const key of Object . keys ( this . _redisState . pool ) ) {
301+ const connection = this . _redisState . pool [ key ]
302302 if ( connection . monitorMode ) return
303303 tasks . push ( connection . sendCommand ( 'monitor' , args ) )
304304 }
@@ -316,13 +316,13 @@ exports.initCommands = function (proto) {
316316 */
317317
318318 proto . evalauto = function ( script , numkeys , key ) {
319- let args = tool . slice ( adjustArgs ( arguments ) )
319+ const args = tool . slice ( adjustArgs ( arguments ) )
320320 script = String ( args [ 0 ] ) . trim ( )
321321
322322 return thunk . call ( this , function * ( ) {
323323 yield this . clientReady
324324
325- let slot = args . length < 3 ? null : calcSlot ( args [ 2 ] )
325+ const slot = args . length < 3 ? null : calcSlot ( args [ 2 ] )
326326 let connection = this . _redisState . getConnection ( slot )
327327 if ( connection instanceof Error ) throw connection
328328
@@ -337,7 +337,7 @@ exports.initCommands = function (proto) {
337337 }
338338 }
339339
340- let res = yield connection . sendCommand ( 'eval' , args )
340+ const res = yield connection . sendCommand ( 'eval' , args )
341341 // connection maybe change with MOVED response
342342 connection = this . _redisState . getConnection ( slot )
343343 if ( connection instanceof Error ) throw connection
@@ -346,14 +346,14 @@ exports.initCommands = function (proto) {
346346 } )
347347 }
348348
349- for ( let command of [ 'psubscribe' , 'punsubscribe' , 'subscribe' , 'unsubscribe' ] ) {
349+ for ( const command of [ 'psubscribe' , 'punsubscribe' , 'subscribe' , 'unsubscribe' ] ) {
350350 proto [ command ] = function ( ) {
351- let args = adjustArgs ( arguments )
351+ const args = adjustArgs ( arguments )
352352 return sendCommand ( this , command , args , args . length ? ( args . length - 1 ) : 0 )
353353 }
354354 }
355355
356- for ( let command of commands ) {
356+ for ( const command of commands ) {
357357 proto [ command . toUpperCase ( ) ] = proto [ command ]
358358 }
359359}
@@ -367,14 +367,14 @@ function adjustArgs (args) {
367367}
368368
369369function toArray ( hash , array ) {
370- for ( let key of Object . keys ( hash ) ) {
370+ for ( const key of Object . keys ( hash ) ) {
371371 array . push ( key , hash [ key ] )
372372 }
373373 return array
374374}
375375
376376function toHash ( array ) {
377- let hash = { }
377+ const hash = { }
378378
379379 for ( let i = 0 , len = array . length ; i < len ; i += 2 ) {
380380 hash [ array [ i ] ] = array [ i + 1 ]
@@ -384,13 +384,13 @@ function toHash (array) {
384384}
385385
386386function formatInfo ( info ) {
387- let hash = { }
387+ const hash = { }
388388
389- for ( let line of info . toString ( ) . split ( '\r\n' ) ) {
390- let index = line . indexOf ( ':' )
389+ for ( const line of info . toString ( ) . split ( '\r\n' ) ) {
390+ const index = line . indexOf ( ':' )
391391
392392 if ( index === - 1 ) continue
393- let name = line . slice ( 0 , index )
393+ const name = line . slice ( 0 , index )
394394 hash [ name ] = line . slice ( index + 1 )
395395 }
396396
0 commit comments