Skip to content

Commit

Permalink
refactor: improve peer inspect message
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 26, 2024
1 parent a3b61f5 commit 9f7e1f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export abstract class Peer<AdapterContext = any> implements WSRequest {
}

[Symbol.for("nodejs.util.inspect.custom")]() {
const _addr = this.addr || "??";
const _id = this.toString();
const _addr = this.addr ? ` (${this.addr})` : "";
const _state =
this.readyState === 1 || this.readyState === -1
? ""
: ` [${ReadyStateMap[this.readyState]}]`;
return `Peer<${_addr}${_state}>`;

return `${_id}${_addr}${_state}`;
}
}

0 comments on commit 9f7e1f0

Please sign in to comment.