From 40de4b1cc4ca14680b47aed99fd60ebd674cc445 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Wed, 8 Apr 2015 08:29:22 -0700 Subject: [PATCH] style --- lib/socket.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/socket.js b/lib/socket.js index 0601741f..6e8eefba 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -206,7 +206,7 @@ Socket.prototype.open = function () { var transport; if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) { transport = 'websocket'; - } else if (0 == this.transports.length) { + } else if (0 === this.transports.length) { // Emit error on next tick so it can be listened to var self = this; setTimeout(function() { @@ -538,7 +538,7 @@ Socket.prototype.onDrain = function() { // and a nonzero prevBufferLen could cause problems on `drain` this.prevBufferLen = 0; - if (this.writeBuffer.length == 0) { + if (0 === this.writeBuffer.length) { this.emit('drain'); } else { this.flush(); @@ -630,24 +630,6 @@ Socket.prototype.close = function () { var self = this; - function close() { - self.onClose('forced close'); - debug('socket closing - telling transport to close'); - self.transport.close(); - } - - function cleanupAndClose() { - self.removeListener('upgrade', cleanupAndClose); - self.removeListener('upgradeError', cleanupAndClose); - close(); - } - - function waitForUpgrade() { - // wait for upgrade to finish since we can't send packets while pausing a transport - self.once('upgrade', cleanupAndClose); - self.once('upgradeError', cleanupAndClose); - } - if (this.writeBuffer.length) { this.once('drain', function() { if (this.upgrading) { @@ -663,6 +645,24 @@ Socket.prototype.close = function () { } } + function close() { + self.onClose('forced close'); + debug('socket closing - telling transport to close'); + self.transport.close(); + } + + function cleanupAndClose() { + self.removeListener('upgrade', cleanupAndClose); + self.removeListener('upgradeError', cleanupAndClose); + close(); + } + + function waitForUpgrade() { + // wait for upgrade to finish since we can't send packets while pausing a transport + self.once('upgrade', cleanupAndClose); + self.once('upgradeError', cleanupAndClose); + } + return this; };