MCPcopy
hub / github.com/socketio/socket.io / decodePacket

Function decodePacket

packages/socket.io/client-dist/socket.io.js:296–320  ·  view source on GitHub ↗
(encodedPacket, binaryType)

Source from the content-addressed store, hash-verified

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);

Callers 5

decodePayloadFunction · 0.90
transformFunction · 0.90
decodePayloadFunction · 0.70
socket.io.jsFile · 0.70

Calls 2

mapBinaryFunction · 0.70
decodeBase64PacketFunction · 0.70

Tested by

no test coverage detected