diff --git a/dist/socket.d.ts b/dist/socket.d.ts
index 0dce129..2b40c20 100644
--- a/dist/socket.d.ts
+++ b/dist/socket.d.ts
@@ -1,6 +1,4 @@
-///
import { Duplex, DuplexEvents, Callback } from "streamx";
-import { write } from "fs";
type AddressFamily = "IPv6" | "IPv4";
interface SocketOptions {
allowHalfOpen?: boolean;
@@ -20,6 +18,9 @@ export default class Socket extends Duplex {
writable: true;
remotePublicKey: Uint8Array;
private _emulateWebsocket;
+ addEventListener: typeof this.addListener;
+ removeEventListener: typeof this.removeListener;
+ send: typeof this.write;
constructor({ allowHalfOpen, remoteAddress, remotePort, remotePublicKey, write, emulateWebsocket, }?: SocketOptions);
private _connecting;
get connecting(): boolean;
@@ -34,11 +35,6 @@ export default class Socket extends Duplex {
port: any;
family: AddressFamily;
};
- addEventListener: (event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents[TEvent] : (...args: any[]) => void) => this;
- on: (event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents[TEvent] : (...args: any[]) => void) => this;
- removeEventListener: (event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents[TEvent] : (...args: any[]) => void) => this;
- off: (event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents[TEvent] : (...args: any[]) => void) => this;
- send: typeof write;
static isIP(input: string): number;
static isIPv4(input: string): boolean;
static isIPv6(input: string): boolean;
diff --git a/dist/socket.js b/dist/socket.js
index 86ae9f1..ad081b6 100644
--- a/dist/socket.js
+++ b/dist/socket.js
@@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const streamx_1 = require("streamx");
-const fs_1 = require("fs");
const IPV4 = "IPv4";
const IPV6 = "IPv6";
class Socket extends streamx_1.Duplex {
@@ -27,6 +26,9 @@ class Socket extends streamx_1.Duplex {
this.remoteFamily = type === 6 ? IPV6 : IPV4;
}
if (this._emulateWebsocket) {
+ this.addEventListener = this.addListener;
+ this.removeEventListener = this.removeListener;
+ this.send = this.write;
this.addEventListener("data", (data) =>
// @ts-ignore
this.emit("message", new MessageEvent("data", { data })));
@@ -83,11 +85,6 @@ class Socket extends streamx_1.Duplex {
family: this.remoteFamily,
};
}
- addEventListener = this.addListener;
- on = this.addListener;
- removeEventListener = this.removeListener;
- off = this.removeListener;
- send = fs_1.write;
static isIP(input) {
if (Socket.isIPv4(input)) {
return 4;