MCPcopy
hub / github.com/di-sukharev/opencommit / packageData

Function packageData

out/cli.cjs:61283–61329  ·  view source on GitHub ↗
(bytes, type2, mimeType, encodingName)

Source from the content-addressed store, hash-verified

61281 }
61282 function fireAProgressEvent(e3, reader) {
61283 const event = new ProgressEvent(e3, {
61284 bubbles: false,
61285 cancelable: false
61286 });
61287 reader.dispatchEvent(event);
61288 }
61289 function packageData(bytes, type2, mimeType, encodingName) {
61290 switch (type2) {
61291 case "DataURL": {
61292 let dataURL = "data:";
61293 const parsed = parseMIMEType(mimeType || "application/octet-stream");
61294 if (parsed !== "failure") {
61295 dataURL += serializeAMimeType(parsed);
61296 }
61297 dataURL += ";base64,";
61298 const decoder = new StringDecoder("latin1");
61299 for (const chunk of bytes) {
61300 dataURL += btoa2(decoder.write(chunk));
61301 }
61302 dataURL += btoa2(decoder.end());
61303 return dataURL;
61304 }
61305 case "Text": {
61306 let encoding = "failure";
61307 if (encodingName) {
61308 encoding = getEncoding(encodingName);
61309 }
61310 if (encoding === "failure" && mimeType) {
61311 const type3 = parseMIMEType(mimeType);
61312 if (type3 !== "failure") {
61313 encoding = getEncoding(type3.parameters.get("charset"));
61314 }
61315 }
61316 if (encoding === "failure") {
61317 encoding = "UTF-8";
61318 }
61319 return decode(bytes, encoding);
61320 }
61321 case "ArrayBuffer": {
61322 const sequence = combineByteSequences(bytes);
61323 return sequence.buffer;
61324 }
61325 case "BinaryString": {
61326 let binaryString = "";
61327 const decoder = new StringDecoder("latin1");
61328 for (const chunk of bytes) {
61329 binaryString += decoder.write(chunk);
61330 }
61331 binaryString += decoder.end();
61332 return binaryString;

Callers 1

readOperationFunction · 0.85

Calls 8

parseMIMETypeFunction · 0.85
serializeAMimeTypeFunction · 0.85
getEncodingFunction · 0.85
decodeFunction · 0.85
combineByteSequencesFunction · 0.85
endMethod · 0.80
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…