refactor: create PeerConstructorOptions type
This commit is contained in:
parent
3accd69ab0
commit
57e2c56d24
|
@ -1,4 +1,4 @@
|
||||||
import { Logger, Peer } from "#types.js";
|
import { Logger, Peer, PeerConstructorOptions } from "#types.js";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import NodeId from "#nodeId.js";
|
import NodeId from "#nodeId.js";
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ export abstract class BasePeer implements Peer {
|
||||||
challenge: Uint8Array;
|
challenge: Uint8Array;
|
||||||
protected _socket: any;
|
protected _socket: any;
|
||||||
|
|
||||||
constructor({ socket, uri }: { socket: any; uri: URL[] }) {
|
constructor({ socket, uris }: PeerConstructorOptions) {
|
||||||
this.connectionUris = uri.map((uri) => new URL(uri.toString()));
|
this.connectionUris = uris.map((uri) => new URL(uri.toString()));
|
||||||
this.challenge = new Uint8Array();
|
this.challenge = new Uint8Array();
|
||||||
this._socket = socket;
|
this._socket = socket;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,11 @@ export interface Peer {
|
||||||
renderLocationUri(): string;
|
renderLocationUri(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PeerConstructorOptions = { socket: any; uris: URL[] };
|
||||||
|
|
||||||
// Define the static side of the class
|
// Define the static side of the class
|
||||||
export interface PeerStatic {
|
export interface PeerStatic {
|
||||||
new ({ socket, uri }: { socket: any; uri: URL[] }): Peer;
|
new ({ socket, uris }: PeerConstructorOptions): Peer;
|
||||||
connect(uri: URL): Promise<any>;
|
connect(uri: URL): Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue