(data, binaryType)
| 417 | }; |
| 418 | |
| 419 | var mapBinary = function mapBinary(data, binaryType) { |
| 420 | switch (binaryType) { |
| 421 | case "blob": |
| 422 | if (data instanceof Blob) { |
| 423 | // from WebSocket + binaryType "blob" |
| 424 | return data; |
| 425 | } else { |
| 426 | // from HTTP long-polling or WebTransport |
| 427 | return new Blob([data]); |
| 428 | } |
| 429 | case "arraybuffer": |
| 430 | default: |
| 431 | if (data instanceof ArrayBuffer) { |
| 432 | // from HTTP long-polling (base64) or WebSocket + binaryType "arraybuffer" |
| 433 | return data; |
| 434 | } else { |
| 435 | // from WebTransport (Uint8Array) |
| 436 | return data.buffer; |
| 437 | } |
| 438 | } |
| 439 | }; |
| 440 | |
| 441 | var SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text |
| 442 | var encodePayload = function encodePayload(packets, callback) { |
no outgoing calls
no test coverage detected