dgram: changed 'var' to 'let' and 'const'

PR-URL: https://github.com/nodejs/node/pull/28357
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Manuel Ochoa Loaiza 2019-06-21 16:45:49 -05:00 committed by Rich Trott
parent 1567461052
commit e5e96fbc35

View File

@ -79,7 +79,7 @@ const RECV_BUFFER = true;
const SEND_BUFFER = false; const SEND_BUFFER = false;
// Lazily loaded // Lazily loaded
var cluster = null; let cluster = null;
const errnoException = errors.errnoException; const errnoException = errors.errnoException;
const exceptionWithHostPort = errors.exceptionWithHostPort; const exceptionWithHostPort = errors.exceptionWithHostPort;
@ -87,7 +87,7 @@ const exceptionWithHostPort = errors.exceptionWithHostPort;
function Socket(type, listener) { function Socket(type, listener) {
EventEmitter.call(this); EventEmitter.call(this);
var lookup; let lookup;
let recvBufferSize; let recvBufferSize;
let sendBufferSize; let sendBufferSize;
@ -262,8 +262,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
return this; return this;
} }
var address; let address;
var exclusive; let exclusive;
if (port !== null && typeof port === 'object') { if (port !== null && typeof port === 'object') {
address = port.address || ''; address = port.address || '';
@ -293,7 +293,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
if (!cluster) if (!cluster)
cluster = require('cluster'); cluster = require('cluster');
var flags = 0; let flags = 0;
if (state.reuseAddr) if (state.reuseAddr)
flags |= UV_UDP_REUSEADDR; flags |= UV_UDP_REUSEADDR;
if (state.ipv6Only) if (state.ipv6Only)
@ -318,7 +318,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
const err = state.handle.bind(ip, port || 0, flags); const err = state.handle.bind(ip, port || 0, flags);
if (err) { if (err) {
var ex = exceptionWithHostPort(err, 'bind', ip, port); const ex = exceptionWithHostPort(err, 'bind', ip, port);
this.emit('error', ex); this.emit('error', ex);
state.bindState = BIND_STATE_UNBOUND; state.bindState = BIND_STATE_UNBOUND;
// Todo: close? // Todo: close?
@ -467,8 +467,8 @@ function sliceBuffer(buffer, offset, length) {
function fixBufferList(list) { function fixBufferList(list) {
const newlist = new Array(list.length); const newlist = new Array(list.length);
for (var i = 0, l = list.length; i < l; i++) { for (let i = 0, l = list.length; i < l; i++) {
var buf = list[i]; const buf = list[i];
if (typeof buf === 'string') if (typeof buf === 'string')
newlist[i] = Buffer.from(buf); newlist[i] = Buffer.from(buf);
else if (!isUint8Array(buf)) else if (!isUint8Array(buf))
@ -514,7 +514,7 @@ function clearQueue() {
state.queue = undefined; state.queue = undefined;
// Flush the send queue. // Flush the send queue.
for (var i = 0; i < queue.length; i++) for (let i = 0; i < queue.length; i++)
queue[i](); queue[i]();
} }
@ -732,8 +732,8 @@ Socket.prototype.remoteAddress = function() {
if (state.connectState !== CONNECT_STATE_CONNECTED) if (state.connectState !== CONNECT_STATE_CONNECTED)
throw new ERR_SOCKET_DGRAM_NOT_CONNECTED(); throw new ERR_SOCKET_DGRAM_NOT_CONNECTED();
var out = {}; const out = {};
var err = state.handle.getpeername(out); const err = state.handle.getpeername(out);
if (err) if (err)
throw errnoException(err, 'getpeername'); throw errnoException(err, 'getpeername');