From 57e2c56d24f039a66329b0ded5f480bd2b9ecc43 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 31 Aug 2023 18:00:59 -0400 Subject: [PATCH] refactor: create PeerConstructorOptions type --- src/transports/base.ts | 6 +++--- src/types.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/transports/base.ts b/src/transports/base.ts index ba865bc..f6d775d 100644 --- a/src/transports/base.ts +++ b/src/transports/base.ts @@ -1,4 +1,4 @@ -import { Logger, Peer } from "#types.js"; +import { Logger, Peer, PeerConstructorOptions } from "#types.js"; import { URL } from "url"; import NodeId from "#nodeId.js"; @@ -8,8 +8,8 @@ export abstract class BasePeer implements Peer { challenge: Uint8Array; protected _socket: any; - constructor({ socket, uri }: { socket: any; uri: URL[] }) { - this.connectionUris = uri.map((uri) => new URL(uri.toString())); + constructor({ socket, uris }: PeerConstructorOptions) { + this.connectionUris = uris.map((uri) => new URL(uri.toString())); this.challenge = new Uint8Array(); this._socket = socket; } diff --git a/src/types.ts b/src/types.ts index cb67475..bfe03ef 100644 --- a/src/types.ts +++ b/src/types.ts @@ -30,9 +30,11 @@ export interface Peer { renderLocationUri(): string; } +export type PeerConstructorOptions = { socket: any; uris: URL[] }; + // Define the static side of the class export interface PeerStatic { - new ({ socket, uri }: { socket: any; uri: URL[] }): Peer; + new ({ socket, uris }: PeerConstructorOptions): Peer; connect(uri: URL): Promise; }