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

Function _deconstructPacket

packages/socket.io/client-dist/socket.io.js:3114–3139  ·  view source on GitHub ↗
(data, buffers)

Source from the content-addressed store, hash-verified

3112 };
3113 }
3114 function _deconstructPacket(data, buffers) {
3115 if (!data) return data;
3116 if (isBinary(data)) {
3117 var placeholder = {
3118 _placeholder: true,
3119 num: buffers.length
3120 };
3121 buffers.push(data);
3122 return placeholder;
3123 } else if (Array.isArray(data)) {
3124 var newData = new Array(data.length);
3125 for (var i = 0; i < data.length; i++) {
3126 newData[i] = _deconstructPacket(data[i], buffers);
3127 }
3128 return newData;
3129 } else if (_typeof(data) === "object" && !(data instanceof Date)) {
3130 var _newData = {};
3131 for (var key in data) {
3132 if (Object.prototype.hasOwnProperty.call(data, key)) {
3133 _newData[key] = _deconstructPacket(data[key], buffers);
3134 }
3135 }
3136 return _newData;
3137 }
3138 return data;
3139 }
3140 /**
3141 * Reconstructs a binary packet from its placeholder packet and buffers
3142 *

Callers 1

deconstructPacketFunction · 0.70

Calls 2

_typeofFunction · 0.85
isBinaryFunction · 0.70

Tested by

no test coverage detected