MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / encodeBlob

Function encodeBlob

sdk/src/CloudSocketClientLib.js:3409–3423  ·  view source on GitHub ↗
(packet, supportsBinary, callback)

Source from the content-addressed store, hash-verified

3407 }
3408
3409 function encodeBlob(packet, supportsBinary, callback) {
3410 if (!supportsBinary) {
3411 return exports.encodeBase64Packet(packet, callback);
3412 }
3413
3414 if (dontSendBlobs) {
3415 return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
3416 }
3417
3418 var length = new Uint8Array(1);
3419 length[0] = packets[packet.type];
3420 var blob = new Blob([length.buffer, packet.data]);
3421
3422 return callback(blob);
3423 }
3424
3425 /**
3426 * Encodes a packet with binary data in a base64 string

Callers 1

Calls 2

encodeBlobAsArrayBufferFunction · 0.70
callbackFunction · 0.70

Tested by

no test coverage detected