Skip to content

Commit

Permalink
Fix typescript style
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Jul 6, 2024
1 parent e1ebde1 commit 2d97b7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion typescript/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export abstract class BaseTransport<T = {}>
if (!response.id) return; // TODO: Handle error.
const handler = this._requests.get(response.id);
if (!handler) return; // TODO: Handle error.
this._requests.delete(response.id)
this._requests.delete(response.id);
if (response.error) handler.reject(response.error);
else handler.resolve(response.result);
}
Expand Down
11 changes: 7 additions & 4 deletions typescript/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class WebsocketTransport extends BaseTransport<WebsocketEvents> {
get connected() {
return this._socket.connected;
}
constructor(public url: string, options?: WebsocketOptions) {
constructor(
public url: string,
options?: WebsocketOptions,
) {
super();
const onmessage = (event: WebSocket.MessageEvent) => {
const message: Message = JSON.parse(event.data as string);
Expand All @@ -36,7 +39,7 @@ export class WebsocketTransport extends BaseTransport<WebsocketEvents> {
this._socket.on("connect", () => this.emit("connect"));
this._socket.on("disconnect", () => this.emit("disconnect"));
this._socket.on("error", (error: WebSocket.ErrorEvent) =>
this.emit("error", error)
this.emit("error", error),
);
}

Expand Down Expand Up @@ -65,7 +68,7 @@ class ReconnectingWebsocket extends Emitter<WebsocketEvents> {
constructor(
public url: string,
onmessage: (event: WebSocket.MessageEvent) => void,
options?: WebsocketOptions
options?: WebsocketOptions,
) {
super();
this.options = {
Expand Down Expand Up @@ -108,7 +111,7 @@ class ReconnectingWebsocket extends Emitter<WebsocketEvents> {
const wait = Math.min(
this.options.reconnectInterval *
Math.pow(this.options.reconnectDecay, this._reconnectAttempts),
this.options.maxReconnectInterval
this.options.maxReconnectInterval,
);
setTimeout(() => {
this._reconnectAttempts += 1;
Expand Down

0 comments on commit 2d97b7a

Please sign in to comment.