(code: number)
| 37 | // Codes 1005/1006/1015 are reserved and cannot be sent in a close frame; |
| 38 | // abnormal upstream drops commonly produce 1006, which would throw on clientWs.close(). |
| 39 | function toClientCloseCode(code: number): number { |
| 40 | return code >= 1000 && code <= 4999 && code !== 1005 && code !== 1006 && code !== 1015 |
| 41 | ? code |
| 42 | : 1011 |
| 43 | } |
| 44 | |
| 45 | function decodeWsText(message: string | ArrayBuffer | Uint8Array): string { |
| 46 | if (typeof message === 'string') return message |