add Socket.prototype; lol (#5945)

This commit is contained in:
dave caruso
2023-09-29 15:42:06 -07:00
committed by GitHub
parent 10bee33909
commit 72bdd380af
4 changed files with 29 additions and 27 deletions

View File

@@ -79,17 +79,15 @@ const Socket = (function (InternalSocket) {
enumerable: false,
});
return Object.defineProperty(
function Socket(options) {
return new InternalSocket(options);
function Socket(options) {
return new InternalSocket(options);
}
Socket.prototype = InternalSocket.prototype;
return Object.defineProperty(Socket, Symbol.hasInstance, {
value(instance) {
return instance instanceof InternalSocket;
},
Symbol.hasInstance,
{
value(instance) {
return instance instanceof InternalSocket;
},
},
);
});
})(
class Socket extends Duplex {
static #Handlers = {

View File

@@ -306,18 +306,15 @@ const TLSSocket = (function (InternalTLSSocket) {
value: "TLSSocket",
enumerable: false,
});
return Object.defineProperty(
function Socket(options) {
return new InternalTLSSocket(options);
function Socket(options) {
return new InternalTLSSocket(options);
}
Socket.prototype = InternalTLSSocket.prototype;
return Object.defineProperty(Socket, Symbol.hasInstance, {
value(instance) {
return instance instanceof InternalTLSSocket;
},
Symbol.hasInstance,
{
value(instance) {
return instance instanceof InternalTLSSocket;
},
},
);
});
})(
class TLSSocket extends InternalTCPSocket {
#secureContext;

File diff suppressed because one or more lines are too long

View File

@@ -411,3 +411,10 @@ it("should handle connection error (unix)", done => {
done();
});
});
it("Socket has a prototype", () => {
function Connection() {}
function Connection2() {}
require("util").inherits(Connection, Socket);
require("util").inherits(Connection2, require("tls").TLSSocket);
});