@relaycorp/ws-mock
Advanced tools
Comparing version 2.4.1 to 2.5.0
@@ -12,2 +12,3 @@ /// <reference types="node" /> | ||
protected ownCloseFrame: CloseFrame | null; | ||
protected _wasTerminated: boolean; | ||
protected readonly messagesSent: WSData[]; | ||
@@ -19,4 +20,6 @@ protected readonly ownEvents: EventEmitter; | ||
close(code?: number, reason?: string): void; | ||
terminate(): void; | ||
get wasTerminated(): boolean; | ||
makeDuplex(): Duplex; | ||
private requireOpenConnection; | ||
} |
@@ -17,2 +17,4 @@ "use strict"; | ||
this.ownCloseFrame = null; | ||
// tslint:disable-next-line:readonly-keyword | ||
this._wasTerminated = false; | ||
// tslint:disable-next-line:readonly-array | ||
@@ -77,2 +79,11 @@ this.messagesSent = []; | ||
} | ||
terminate() { | ||
this.requireOpenConnection(); | ||
// tslint:disable-next-line:no-object-mutation | ||
this._wasTerminated = true; | ||
this.ownEvents.emit('termination'); | ||
} | ||
get wasTerminated() { | ||
return this._wasTerminated; | ||
} | ||
makeDuplex() { | ||
@@ -84,3 +95,5 @@ // tslint:disable-next-line:no-this-assignment | ||
destroy(error, callback) { | ||
connection.emit('close', error ? 1006 : 1005); | ||
if (!connection.wasTerminated) { | ||
connection.emit('close', error ? 1006 : 1005); | ||
} | ||
callback(error); | ||
@@ -98,2 +111,3 @@ }, | ||
this.once('close', () => duplex.destroy()); | ||
this.ownEvents.once('termination', () => duplex.destroy()); | ||
this.once('error', (error) => duplex.destroy(error)); | ||
@@ -106,2 +120,5 @@ return duplex; | ||
} | ||
if (this.wasTerminated) { | ||
throw new Error('Connection was terminated'); | ||
} | ||
} | ||
@@ -108,0 +125,0 @@ } |
@@ -12,2 +12,3 @@ /// <reference types="node" /> | ||
protected ownCloseFrame: CloseFrame | null; | ||
protected _wasTerminated: boolean; | ||
protected readonly messagesSent: WSData[]; | ||
@@ -19,4 +20,6 @@ protected readonly ownEvents: EventEmitter; | ||
close(code?: number, reason?: string): void; | ||
terminate(): void; | ||
get wasTerminated(): boolean; | ||
makeDuplex(): Duplex; | ||
private requireOpenConnection; | ||
} |
@@ -12,2 +12,4 @@ import { EventEmitter } from 'events'; | ||
ownCloseFrame = null; | ||
// tslint:disable-next-line:readonly-keyword | ||
_wasTerminated = false; | ||
// tslint:disable-next-line:readonly-array | ||
@@ -71,2 +73,11 @@ messagesSent = []; | ||
} | ||
terminate() { | ||
this.requireOpenConnection(); | ||
// tslint:disable-next-line:no-object-mutation | ||
this._wasTerminated = true; | ||
this.ownEvents.emit('termination'); | ||
} | ||
get wasTerminated() { | ||
return this._wasTerminated; | ||
} | ||
makeDuplex() { | ||
@@ -78,3 +89,5 @@ // tslint:disable-next-line:no-this-assignment | ||
destroy(error, callback) { | ||
connection.emit('close', error ? 1006 : 1005); | ||
if (!connection.wasTerminated) { | ||
connection.emit('close', error ? 1006 : 1005); | ||
} | ||
callback(error); | ||
@@ -92,2 +105,3 @@ }, | ||
this.once('close', () => duplex.destroy()); | ||
this.ownEvents.once('termination', () => duplex.destroy()); | ||
this.once('error', (error) => duplex.destroy(error)); | ||
@@ -100,2 +114,5 @@ return duplex; | ||
} | ||
if (this.wasTerminated) { | ||
throw new Error('Connection was terminated'); | ||
} | ||
} | ||
@@ -102,0 +119,0 @@ } |
{ | ||
"name": "@relaycorp/ws-mock", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"author": { | ||
@@ -45,3 +45,3 @@ "email": "no-reply@relaycorp.tech", | ||
"prettier": "^2.3.2", | ||
"ts-node": "^10.1.0", | ||
"ts-node": "^10.2.0", | ||
"tslint": "^5.20.1", | ||
@@ -48,0 +48,0 @@ "typedoc": "^0.21.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63227
1089