chore(): ws client tidying and misc improvements

This commit is contained in:
tiagosiebler
2025-01-24 12:44:01 +00:00
parent 9c12727b9d
commit ee23e13710
4 changed files with 166 additions and 265 deletions

View File

@@ -1,31 +1,30 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
import { WebsocketClient, WsClientEvent } from '../src';
import { DefaultLogger, WebsocketClient } from '../src';
export function getSilentLogger(_logHint?: string) {
export function getSilentLogger(_logHint?: string): typeof DefaultLogger {
return {
silly: () => {},
debug: () => {},
notice: () => {},
trace: () => {},
info: () => {},
warning: () => {},
error: () => {},
};
}
export const fullLogger = {
silly: (...params) => console.log('silly', ...params),
debug: (...params) => console.log('debug', ...params),
notice: (...params) => console.log('notice', ...params),
export const fullLogger: typeof DefaultLogger = {
trace: (...params) => console.log('trace', ...params),
info: (...params) => console.info('info', ...params),
warning: (...params) => console.warn('warning', ...params),
error: (...params) => console.error('error', ...params),
};
export const WS_OPEN_EVENT_PARTIAL = {
type: 'open',
};
export type WsClientEvent =
| 'open'
| 'update'
| 'close'
| 'error'
| 'reconnect'
| 'reconnected'
| 'response';
/** Resolves a promise if an event is seen before a timeout (defaults to 4.5 seconds) */
export function waitForSocketEvent(