refactor: update Peer constructor to take an object bag

This commit is contained in:
Derrick Hammer 2023-08-31 17:53:44 -04:00
parent 215a4ce4fe
commit a84c02c36f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 5 additions and 5 deletions

View File

@ -3,15 +3,15 @@ import { URL } from "url";
import NodeId from "#nodeId.js";
export abstract class BasePeer implements Peer {
connectionUris: Array<URL>;
connectionUris: URL[];
isConnected: boolean = false;
challenge: Uint8Array;
protected _socket: any;
constructor(_socket: any, connectionUris: URL[]) {
this.connectionUris = connectionUris.map((uri) => new URL(uri.toString()));
constructor({ socket, uri }: { socket: any; uri: URL[] }) {
this.connectionUris = uri.map((uri) => new URL(uri.toString()));
this.challenge = new Uint8Array();
this._socket = _socket;
this._socket = socket;
}
private _id?: NodeId;

View File

@ -32,7 +32,7 @@ export interface Peer {
// Define the static side of the class
export interface PeerStatic {
new (_socket: any, uri: URL[]): Peer;
new ({ socket, uri }: { socket: any; uri: URL[] }): Peer;
connect(uri: URL): Promise<any>;
}