Use efficient filters

This commit is contained in:
Andras Schmelczer 2025-12-07 11:30:19 +00:00
parent 07cb8491e2
commit 3f2ecfb0b6
13 changed files with 82 additions and 47 deletions

View file

@ -8,6 +8,7 @@ import { createPromise } from "../utils/create-promise";
import type { WebSocketVaultUpdate } from "./types/WebSocketVaultUpdate";
import { awaitAll } from "../utils/await-all";
import { WEBSOCKET_DISCONNECT_TIMEOUT_IN_S } from "../consts";
import { removeFromArray } from "../utils/remove-from-array";
export class WebSocketManager {
private readonly webSocketStatusChangeListeners: ((
@ -227,12 +228,10 @@ export class WebSocketManager {
);
})
.finally(() => {
const index = this.outstandingPromises.indexOf(
removeFromArray(
this.outstandingPromises,
messageHandlingPromise
);
if (index !== -1) {
void this.outstandingPromises.splice(index, 1); // ignore the returned promise
}
});
void this.outstandingPromises.push(messageHandlingPromise); // ignore the returned promise