@@ -91,7 +91,7 @@ for(var methodName in commands) {
9191
9292// Handle parsed chat server message..
9393client . prototype . handleMessage = function handleMessage ( message ) {
94- if ( _ . isNull ( message ) ) {
94+ if ( ! message ) {
9595 return ;
9696 }
9797
@@ -120,7 +120,7 @@ client.prototype.handleMessage = function handleMessage(message) {
120120 }
121121
122122 // Messages with no prefix..
123- if ( _ . isNull ( message . prefix ) ) {
123+ if ( message . prefix === null ) {
124124 switch ( message . command ) {
125125 // Received PING from server..
126126 case "PING" :
@@ -177,7 +177,7 @@ client.prototype.handleMessage = function handleMessage(message) {
177177 }
178178 this . latency = new Date ( ) ;
179179 this . pingTimeout = setTimeout ( ( ) => {
180- if ( ! _ . isNull ( this . ws ) ) {
180+ if ( this . ws !== null ) {
181181 this . wasCloseCalled = false ;
182182 this . log . error ( "Ping timeout." ) ;
183183 this . ws . close ( ) ;
@@ -780,7 +780,7 @@ client.prototype.handleMessage = function handleMessage(message) {
780780 // Duration returns null if it's a ban, otherwise it's a timeout..
781781 var duration = _ . get ( message . tags [ "ban-duration" ] , null ) ;
782782
783- if ( _ . isNull ( duration ) ) {
783+ if ( duration === null ) {
784784 this . log . info ( `[${ channel } ] ${ msg } has been banned.` ) ;
785785 this . emit ( "ban" , channel , msg , null , message . tags ) ;
786786 }
@@ -1127,7 +1127,7 @@ client.prototype._openConnection = function _openConnection() {
11271127// Called when the WebSocket connection's readyState changes to OPEN.
11281128// Indicates that the connection is ready to send and receive data..
11291129client . prototype . _onOpen = function _onOpen ( ) {
1130- if ( _ . isNull ( this . ws ) || this . ws . readyState !== 1 ) {
1130+ if ( ! this . _isConnected ( ) ) {
11311131 return ;
11321132 }
11331133
@@ -1195,7 +1195,7 @@ client.prototype._onError = function _onError() {
11951195 clearInterval ( this . pingLoop ) ;
11961196 clearTimeout ( this . pingTimeout ) ;
11971197
1198- this . reason = ! _ . isNull ( this . ws ) ? "Unable to connect ." : "Connection closed ." ;
1198+ this . reason = this . ws === null ? "Connection closed ." : "Unable to connect ." ;
11991199
12001200 this . emits ( [ "_promiseConnect" , "disconnected" ] , [ [ this . reason ] ] ) ;
12011201
@@ -1270,7 +1270,7 @@ client.prototype._sendCommand = function _sendCommand(delay, channel, command, f
12701270 // Race promise against delay..
12711271 return new Promise ( ( resolve , reject ) => {
12721272 // Make sure the socket is opened..
1273- if ( _ . isNull ( this . ws ) || this . ws . readyState !== 1 ) {
1273+ if ( ! this . _isConnected ( ) ) {
12741274 // Disconnected from server..
12751275 return reject ( "Not connected to server." ) ;
12761276 }
@@ -1279,7 +1279,7 @@ client.prototype._sendCommand = function _sendCommand(delay, channel, command, f
12791279 }
12801280
12811281 // Executing a command on a channel..
1282- if ( ! _ . isNull ( channel ) ) {
1282+ if ( channel !== null ) {
12831283 var chan = _ . channel ( channel ) ;
12841284 this . log . info ( `[${ chan } ] Executing command: ${ command } ` ) ;
12851285 this . ws . send ( `PRIVMSG ${ chan } :${ command } ` ) ;
@@ -1304,7 +1304,7 @@ client.prototype._sendMessage = function _sendMessage(delay, channel, message, f
13041304 // Promise a result..
13051305 return new Promise ( ( resolve , reject ) => {
13061306 // Make sure the socket is opened and not logged in as a justinfan user..
1307- if ( _ . isNull ( this . ws ) || this . ws . readyState !== 1 ) {
1307+ if ( ! this . _isConnected ( ) ) {
13081308 return reject ( "Not connected to server." ) ;
13091309 }
13101310 else if ( _ . isJustinfan ( this . getUsername ( ) ) ) {
@@ -1331,7 +1331,7 @@ client.prototype._sendMessage = function _sendMessage(delay, channel, message, f
13311331 Object . keys ( this . emotesets ) . forEach ( id =>
13321332 this . emotesets [ id ] . forEach ( emote => {
13331333 var emoteFunc = _ . isRegex ( emote . code ) ? parse . emoteRegex : parse . emoteString ;
1334- return emoteFunc ( message , emote . code , emote . id , emotes )
1334+ return emoteFunc ( message , emote . code , emote . id , emotes ) ;
13351335 } )
13361336 ) ;
13371337
@@ -1341,7 +1341,7 @@ client.prototype._sendMessage = function _sendMessage(delay, channel, message, f
13411341 parse . emotes ( { emotes : parse . transformEmotes ( emotes ) || null } )
13421342 ) ;
13431343
1344- var messagesLogLevel = _ . get ( this . opts . options . messagesLogLevel , "info" )
1344+ var messagesLogLevel = _ . get ( this . opts . options . messagesLogLevel , "info" ) ;
13451345
13461346 // Message is an action (/me <message>)..
13471347 var actionMessage = _ . actionMessage ( message ) ;
@@ -1418,20 +1418,19 @@ client.prototype.isMod = function isMod(channel, username) {
14181418
14191419// Get readyState..
14201420client . prototype . readyState = function readyState ( ) {
1421- if ( _ . isNull ( this . ws ) ) { return "CLOSED" ; }
1421+ if ( this . ws === null ) { return "CLOSED" ; }
14221422 return [ "CONNECTING" , "OPEN" , "CLOSING" , "CLOSED" ] [ this . ws . readyState ] ;
14231423} ;
14241424
14251425// Determine if the client has a WebSocket and it's open..
14261426client . prototype . _isConnected = function _isConnected ( ) {
1427-
14281427 return this . ws !== null && this . ws . readyState === 1 ;
14291428}
14301429
14311430// Disconnect from server..
14321431client . prototype . disconnect = function disconnect ( ) {
14331432 return new Promise ( ( resolve , reject ) => {
1434- if ( ! _ . isNull ( this . ws ) && this . ws . readyState !== 3 ) {
1433+ if ( this . ws !== null && this . ws . readyState !== 3 ) {
14351434 this . wasCloseCalled = true ;
14361435 this . log . info ( "Disconnecting from server.." ) ;
14371436 this . ws . close ( ) ;
0 commit comments