Simplify `this.isActive() && this.webSocket` into `this.isActive()`

in Connection#close. We can do this because `isActive()` can only
return `true` if `this.webSocket` is truthy. (We can't have an active
connection without having instantiated a WebSocket. This is confirmed
in the code: Connection#isActive calls Connection#isState which calls
Connection#getState, which checks if `this.webSocket` is truthy and
returns `null` otherwise.)
This commit is contained in:
Richard Macklin 2019-01-14 11:36:32 -08:00
parent 6320916513
commit 739f88e52e
2 changed files with 2 additions and 2 deletions

View File

@ -191,7 +191,7 @@
if (!allowReconnect) {
this.monitor.stop();
}
if (this.isActive() && this.webSocket) {
if (this.isActive()) {
return this.webSocket.close();
}
};

View File

@ -44,7 +44,7 @@ class Connection {
close({allowReconnect} = {allowReconnect: true}) {
if (!allowReconnect) { this.monitor.stop() }
if (this.isActive() && this.webSocket) {
if (this.isActive()) {
return this.webSocket.close()
}
}