From a84c02c36f63b751a793bd69eff36dee601752c8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 31 Aug 2023 17:53:44 -0400 Subject: [PATCH] refactor: update Peer constructor to take an object bag --- src/transports/base.ts | 8 ++++---- src/types.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transports/base.ts b/src/transports/base.ts index f34bfe2..ba865bc 100644 --- a/src/transports/base.ts +++ b/src/transports/base.ts @@ -3,15 +3,15 @@ import { URL } from "url"; import NodeId from "#nodeId.js"; export abstract class BasePeer implements Peer { - connectionUris: Array; + 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; diff --git a/src/types.ts b/src/types.ts index 464a58f..cb67475 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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; }