New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@d-fischer/connection

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d-fischer/connection - npm Package Compare versions

Comparing version 3.0.4 to 4.0.0

3

lib/Connection.d.ts

@@ -20,3 +20,3 @@ /// <reference types="node" />

connect(): Promise<void>;
disconnect(manually?: boolean): void;
disconnect(manually?: boolean): Promise<void>;
destroy(): void;

@@ -30,2 +30,3 @@ sendLine(line: string): void;

protected abstract doConnect(): Promise<void>;
protected abstract doDisconnect(): Promise<void>;
protected abstract sendRaw(line: string): void;

@@ -32,0 +33,0 @@ abstract get hasSocket(): boolean;

@@ -42,6 +42,17 @@ "use strict";

if (manually === void 0) { manually = true; }
if (this.hasSocket && manually) {
this._manualDisconnect = true;
}
this.destroy();
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.hasSocket && manually) {
this._manualDisconnect = true;
}
return [4 /*yield*/, this.doDisconnect()];
case 1:
_a.sent();
this._handleDisconnect();
return [2 /*return*/];
}
});
});
};

@@ -48,0 +59,0 @@ Connection.prototype.destroy = function () {

@@ -5,7 +5,8 @@ import Connection from './Connection';

get port(): number;
doConnect(): Promise<void>;
get hasSocket(): boolean;
destroy(): void;
sendRaw(line: string): void;
protected doConnect(): Promise<void>;
protected doDisconnect(): Promise<void>;
}
export default DirectConnection;

@@ -19,2 +19,21 @@ "use strict";

});
Object.defineProperty(DirectConnection.prototype, "hasSocket", {
get: function () {
return !!this._socket;
},
enumerable: true,
configurable: true
});
DirectConnection.prototype.destroy = function () {
if (this._socket) {
this._socket.destroy();
this._socket = undefined;
}
_super.prototype.destroy.call(this);
};
DirectConnection.prototype.sendRaw = function (line) {
if (this._socket) {
this._socket.write(line);
}
};
DirectConnection.prototype.doConnect = function () {

@@ -58,21 +77,18 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

};
Object.defineProperty(DirectConnection.prototype, "hasSocket", {
get: function () {
return !!this._socket;
},
enumerable: true,
configurable: true
});
DirectConnection.prototype.destroy = function () {
if (this._socket) {
this._socket.destroy();
this._socket = undefined;
}
_super.prototype.destroy.call(this);
DirectConnection.prototype.doDisconnect = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this._socket) return [3 /*break*/, 2];
return [4 /*yield*/, new Promise(function (resolve) { return _this._socket.end(function () { return resolve; }); })];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
});
});
};
DirectConnection.prototype.sendRaw = function (line) {
if (this._socket) {
this._socket.write(line);
}
};
return DirectConnection;

@@ -79,0 +95,0 @@ }(Connection_1.default));

@@ -5,7 +5,8 @@ import Connection from './Connection';

get port(): number;
doConnect(): Promise<void>;
get hasSocket(): boolean;
destroy(): void;
sendRaw(line: string): void;
protected doConnect(): Promise<void>;
protected doDisconnect(): Promise<void>;
}
export default WebSocketConnection;

@@ -18,2 +18,21 @@ "use strict";

});
Object.defineProperty(WebSocketConnection.prototype, "hasSocket", {
get: function () {
return !!this._socket;
},
enumerable: true,
configurable: true
});
WebSocketConnection.prototype.destroy = function () {
if (this._socket) {
this._socket.close();
this._socket = undefined;
}
_super.prototype.destroy.call(this);
};
WebSocketConnection.prototype.sendRaw = function (line) {
if (this._socket) {
this._socket.send(line);
}
};
WebSocketConnection.prototype.doConnect = function () {

@@ -39,11 +58,10 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

_this._socket.onerror = function () { };
_this._socket.onclose = function (_a) {
var wasClean = _a.wasClean, code = _a.code, reason = _a.reason;
_this._socket.onclose = function (e) {
_this._connected = false;
_this._connecting = false;
if (wasClean) {
if (e.wasClean) {
_this._handleDisconnect();
}
else {
var err = new Error("[" + code + "] " + reason);
var err = new Error("[" + e.code + "] " + e.reason);
_this._handleDisconnect(err);

@@ -57,21 +75,11 @@ reject(err);

};
Object.defineProperty(WebSocketConnection.prototype, "hasSocket", {
get: function () {
return !!this._socket;
},
enumerable: true,
configurable: true
});
WebSocketConnection.prototype.destroy = function () {
if (this._socket) {
this._socket.close();
this._socket = undefined;
}
_super.prototype.destroy.call(this);
WebSocketConnection.prototype.doDisconnect = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
(_a = this._socket) === null || _a === void 0 ? void 0 : _a.close();
return [2 /*return*/];
});
});
};
WebSocketConnection.prototype.sendRaw = function (line) {
if (this._socket) {
this._socket.send(line);
}
};
return WebSocketConnection;

@@ -78,0 +86,0 @@ }(Connection_1.default));

{
"name": "@d-fischer/connection",
"version": "3.0.4",
"version": "4.0.0",
"description": "Abstraction for packet-based connections.",

@@ -5,0 +5,0 @@ "keywords": [],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc