(encodedPacket, binaryType)
| 294 | |
| 295 | var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function"; |
| 296 | var decodePacket = function decodePacket(encodedPacket, binaryType) { |
| 297 | if (typeof encodedPacket !== "string") { |
| 298 | return { |
| 299 | type: "message", |
| 300 | data: mapBinary(encodedPacket, binaryType) |
| 301 | }; |
| 302 | } |
| 303 | var type = encodedPacket.charAt(0); |
| 304 | if (type === "b") { |
| 305 | return { |
| 306 | type: "message", |
| 307 | data: decodeBase64Packet(encodedPacket.substring(1), binaryType) |
| 308 | }; |
| 309 | } |
| 310 | var packetType = PACKET_TYPES_REVERSE[type]; |
| 311 | if (!packetType) { |
| 312 | return ERROR_PACKET; |
| 313 | } |
| 314 | return encodedPacket.length > 1 ? { |
| 315 | type: PACKET_TYPES_REVERSE[type], |
| 316 | data: encodedPacket.substring(1) |
| 317 | } : { |
| 318 | type: PACKET_TYPES_REVERSE[type] |
| 319 | }; |
| 320 | }; |
| 321 | var decodeBase64Packet = function decodeBase64Packet(data, binaryType) { |
| 322 | if (withNativeArrayBuffer$1) { |
| 323 | var decoded = decode$1(data); |
no test coverage detected