(data, binaryType)
| 330 | } |
| 331 | }; |
| 332 | var mapBinary = function mapBinary(data, binaryType) { |
| 333 | switch (binaryType) { |
| 334 | case "blob": |
| 335 | if (data instanceof Blob) { |
| 336 | // from WebSocket + binaryType "blob" |
| 337 | return data; |
| 338 | } else { |
| 339 | // from HTTP long-polling or WebTransport |
| 340 | return new Blob([data]); |
| 341 | } |
| 342 | case "arraybuffer": |
| 343 | default: |
| 344 | if (data instanceof ArrayBuffer) { |
| 345 | // from HTTP long-polling (base64) or WebSocket + binaryType "arraybuffer" |
| 346 | return data; |
| 347 | } else { |
| 348 | // from WebTransport (Uint8Array) |
| 349 | return data.buffer; |
| 350 | } |
| 351 | } |
| 352 | }; |
| 353 | |
| 354 | var SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text |
| 355 | var encodePayload = function encodePayload(packets, callback) { |
no outgoing calls
no test coverage detected