From 9dfa636083e825d81b6379a4e5f5302051c7ec84 Mon Sep 17 00:00:00 2001 From: Manuel Ochoa Loaiza Date: Fri, 21 Jun 2019 16:45:49 -0500 Subject: [PATCH] dgram: changed 'var' to 'let' and 'const' PR-URL: https://github.com/nodejs/node/pull/28357 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Jiawen Geng Reviewed-By: Rich Trott --- lib/dgram.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index e032a6f7fdcfb5..923463cc2e7e08 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -79,7 +79,7 @@ const RECV_BUFFER = true; const SEND_BUFFER = false; // Lazily loaded -var cluster = null; +let cluster = null; const errnoException = errors.errnoException; const exceptionWithHostPort = errors.exceptionWithHostPort; @@ -87,7 +87,7 @@ const exceptionWithHostPort = errors.exceptionWithHostPort; function Socket(type, listener) { EventEmitter.call(this); - var lookup; + let lookup; let recvBufferSize; let sendBufferSize; @@ -262,8 +262,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { return this; } - var address; - var exclusive; + let address; + let exclusive; if (port !== null && typeof port === 'object') { address = port.address || ''; @@ -293,7 +293,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { if (!cluster) cluster = require('cluster'); - var flags = 0; + let flags = 0; if (state.reuseAddr) flags |= UV_UDP_REUSEADDR; if (state.ipv6Only) @@ -318,7 +318,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { const err = state.handle.bind(ip, port || 0, flags); if (err) { - var ex = exceptionWithHostPort(err, 'bind', ip, port); + const ex = exceptionWithHostPort(err, 'bind', ip, port); this.emit('error', ex); state.bindState = BIND_STATE_UNBOUND; // Todo: close? @@ -467,8 +467,8 @@ function sliceBuffer(buffer, offset, length) { function fixBufferList(list) { const newlist = new Array(list.length); - for (var i = 0, l = list.length; i < l; i++) { - var buf = list[i]; + for (let i = 0, l = list.length; i < l; i++) { + const buf = list[i]; if (typeof buf === 'string') newlist[i] = Buffer.from(buf); else if (!isUint8Array(buf)) @@ -514,7 +514,7 @@ function clearQueue() { state.queue = undefined; // Flush the send queue. - for (var i = 0; i < queue.length; i++) + for (let i = 0; i < queue.length; i++) queue[i](); } @@ -732,8 +732,8 @@ Socket.prototype.remoteAddress = function() { if (state.connectState !== CONNECT_STATE_CONNECTED) throw new ERR_SOCKET_DGRAM_NOT_CONNECTED(); - var out = {}; - var err = state.handle.getpeername(out); + const out = {}; + const err = state.handle.getpeername(out); if (err) throw errnoException(err, 'getpeername');