| 28 | * via the documented WebSocket option. |
| 29 | */ |
| 30 | export function createJsonWebSocketFactory(): typeof WebSocket { |
| 31 | return class extends WebSocket { |
| 32 | constructor(url: string | URL, protocols?: string | string[]) { |
| 33 | const filtered = Array.isArray(protocols) |
| 34 | ? protocols.filter(p => p !== JUPYTER_BINARY_PROTOCOL) |
| 35 | : protocols === JUPYTER_BINARY_PROTOCOL |
| 36 | ? undefined |
| 37 | : protocols |
| 38 | super(url, filtered) |
| 39 | } |
| 40 | } as typeof WebSocket |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Client for communicating with a Jupyter kernel via the Jupyter protocol. |