(encodedPacket, binaryType)
| 380 | |
| 381 | var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function"; |
| 382 | var decodePacket = function decodePacket(encodedPacket, binaryType) { |
| 383 | if (typeof encodedPacket !== "string") { |
| 384 | return { |
| 385 | type: "message", |
| 386 | data: mapBinary(encodedPacket, binaryType) |
| 387 | }; |
| 388 | } |
| 389 | var type = encodedPacket.charAt(0); |
| 390 | if (type === "b") { |
| 391 | return { |
| 392 | type: "message", |
| 393 | data: decodeBase64Packet(encodedPacket.substring(1), binaryType) |
| 394 | }; |
| 395 | } |
| 396 | var packetType = PACKET_TYPES_REVERSE[type]; |
| 397 | if (!packetType) { |
| 398 | return ERROR_PACKET; |
| 399 | } |
| 400 | return encodedPacket.length > 1 ? { |
| 401 | type: PACKET_TYPES_REVERSE[type], |
| 402 | data: encodedPacket.substring(1) |
| 403 | } : { |
| 404 | type: PACKET_TYPES_REVERSE[type] |
| 405 | }; |
| 406 | }; |
| 407 | var decodeBase64Packet = function decodeBase64Packet(data, binaryType) { |
| 408 | if (withNativeArrayBuffer$1) { |
| 409 | var decoded = decode$1(data); |
no test coverage detected