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

Function encodePacket

packages/socket.io/client-dist/socket.io.js:208–226  ·  view source on GitHub ↗
(_ref, supportsBinary, callback)

Source from the content-addressed store, hash-verified

206 return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
207 };
208 var encodePacket = function encodePacket(_ref, supportsBinary, callback) {
209 var type = _ref.type,
210 data = _ref.data;
211 if (withNativeBlob$1 && data instanceof Blob) {
212 if (supportsBinary) {
213 return callback(data);
214 } else {
215 return encodeBlobAsBase64(data, callback);
216 }
217 } else if (withNativeArrayBuffer$2 && (data instanceof ArrayBuffer || isView$1(data))) {
218 if (supportsBinary) {
219 return callback(data);
220 } else {
221 return encodeBlobAsBase64(new Blob([data]), callback);
222 }
223 }
224 // plain string
225 return callback(PACKET_TYPES[type] + (data || ""));
226 };
227 var encodeBlobAsBase64 = function encodeBlobAsBase64(data, callback) {
228 var fileReader = new FileReader();
229 fileReader.onload = function () {

Callers 4

encodePayloadFunction · 0.90
encodePacketToBinaryFunction · 0.70
encodePayloadFunction · 0.70
_loopFunction · 0.70

Calls 3

isView$1Function · 0.85
callbackFunction · 0.70
encodeBlobAsBase64Function · 0.70

Tested by

no test coverage detected