Skip to content

Commit ce88400

Browse files
committed
refactor: simplify inspect values
1 parent cf9c4fe commit ce88400

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

examples/srvx/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ serve({
99
},
1010

1111
message(peer, message) {
12-
console.log("[ws] message", peer, message);
12+
console.log("[ws] message", message);
1313
if (message.text().includes("ping")) {
1414
peer.send({ user: "server", message: "pong" });
1515
} else {

src/message.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ export class Message implements Partial<MessageEvent> {
196196
return this.text();
197197
}
198198

199-
[kNodeInspect](): { data: unknown } {
200-
return { data: this.rawData };
199+
[kNodeInspect](): unknown {
200+
return {
201+
message: {
202+
id: this.id,
203+
peer: this.peer,
204+
text: this.text(),
205+
},
206+
};
201207
}
202208
}

src/peer.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,13 @@ export abstract class Peer<Internal extends AdapterInternal = AdapterInternal> {
117117
return "WebSocket";
118118
}
119119

120-
[kNodeInspect](): Record<string, unknown> {
121-
return Object.fromEntries(
122-
[
123-
["id", this.id],
124-
["remoteAddress", this.remoteAddress],
125-
["peers", this.peers],
126-
["webSocket", this.websocket],
127-
].filter((p) => p[1]),
128-
);
120+
[kNodeInspect](): unknown {
121+
return {
122+
peer: {
123+
id: this.id,
124+
ip: this.remoteAddress,
125+
},
126+
};
129127
}
130128
}
131129

0 commit comments

Comments
 (0)