Skip to content

Add type guards for ws events #190

@tiagosiebler

Description

@tiagosiebler

Implementation would be easier for websockets if the library included pre-built type guards to narrow down types.

export function isWsFuturesUserDataEvent(
  data: WsFormattedMessage
): data is WsMessageFuturesUserDataEventFormatted {
  // The wsKey can be parsed to determine the type of message (what websocket it came from)
  return !Array.isArray(data) && data.wsKey.includes('userData');
}

Could put these under util/typeGuards.ts

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions