Skip to content

Commit

Permalink
Beautify the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkristian committed Jun 11, 2024
1 parent f65b640 commit 8d6ab3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class RawSocket extends Stream.Duplex {
this.log.trace('< %j', packet);
this.isReading = this.push(packet);
} else {
this.log.debug('buffer overflow %s', guts.getFrameSummary(frame));
this.log.debug('receive buffer overflow %s', guts.getFrameSummary(frame));
}
} catch(err) {
this.log.debug('onFrameFromAGW(%s)', guts.getFrameSummary(frame));
Expand Down
14 changes: 7 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class Throttle extends Stream.Writable {
sender.on('notFull', function() {
that.sendBuffer();
});
this.on('close', function() {that._closed = true;});
this.once('close', function() {that.isClosed = true;});
this.on('pipe', function(from) {
that.log.trace('pipe from %s', from.constructor.name);
});
Expand Down Expand Up @@ -434,7 +434,7 @@ class Throttle extends Stream.Writable {

_destroy(err, callback) {
this.log.debug('_destroy(%s, %s)', err || '', typeof callback);
if (!this._closed) this.emit('close');
if (!this.isClosed) this.emit('close');
if (callback) callback();
}
} // Throttle
Expand Down Expand Up @@ -719,8 +719,8 @@ class Connection extends Stream.Duplex {
this.remoteAddress = toAGW.theirCall;
this._pushable = false;
const that = this;
this.on('end', function() {that._ended = true;});
this.on('close', function() {that._closed = true;});
this.once('end', function() {that.isEnded = true;});
this.once('close', function() {that.isClosed = true;});
this.on('pipe', function(from) {
that.log.trace('pipe from %s', from.constructor.name);
});
Expand All @@ -740,7 +740,7 @@ class Connection extends Stream.Duplex {
this.destroy();
break;
case 'D': // data
if (this._closed) {
if (this.isClosed) {
this.emit('error', newError('received data after close '
+ getDataSummary(frame.data)));
} else if (!this._pushable) {
Expand Down Expand Up @@ -776,8 +776,8 @@ class Connection extends Stream.Duplex {
// The documentation seems to say this.destroy() should emit
// 'end' and 'close', but I find that doesn't always happen.
// This works reliably:
if (!this._ended) this.emit('end');
if (!this._closed) this.emit('close');
if (!this.isEnded) this.emit('end');
if (!this.isClosed) this.emit('close');
if (callback) callback(err);
}

Expand Down

0 comments on commit 8d6ab3e

Please sign in to comment.