ThemeParks.wiki Parks API - v2.0.0
    Preparing search index...

    Function wsMessages

    • Wrap a WebSocket-like object as an async iterable of message events.

      Supports both browser-style WebSocket (addEventListener/removeEventListener) and Node.js EventEmitter-style (on/off).

      • Returns cleanly when the socket emits 'close'.
      • Throws when the socket emits 'error'. Any messages received before the error are yielded first; the error is thrown when the consumer tries to read the next message. Consumers should wrap the for-await loop in try/catch to distinguish clean close from connection failure (and decide whether to reconnect).

      Parameters

      • ws: WebSocketLike

      Returns AsyncGenerator<MessageEvent>