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

Function sliceBlob

out/cli.cjs:9045–9073  ·  view source on GitHub ↗
(blobParts, blobSize, start = 0, end)

Source from the content-addressed store, hash-verified

9043 }
9044}
9045function* sliceBlob(blobParts, blobSize, start = 0, end) {
9046 end !== null && end !== void 0 ? end : end = blobSize;
9047 let relativeStart = start < 0 ? Math.max(blobSize + start, 0) : Math.min(start, blobSize);
9048 let relativeEnd = end < 0 ? Math.max(blobSize + end, 0) : Math.min(end, blobSize);
9049 const span = Math.max(relativeEnd - relativeStart, 0);
9050 let added = 0;
9051 for (const part of blobParts) {
9052 if (added >= span) {
9053 break;
9054 }
9055 const partSize = ArrayBuffer.isView(part) ? part.byteLength : part.size;
9056 if (relativeStart && partSize <= relativeStart) {
9057 relativeStart -= partSize;
9058 relativeEnd -= partSize;
9059 } else {
9060 let chunk;
9061 if (ArrayBuffer.isView(part)) {
9062 chunk = part.subarray(relativeStart, Math.min(partSize, relativeEnd));
9063 added += chunk.byteLength;
9064 } else {
9065 chunk = part.slice(relativeStart, Math.min(partSize, relativeEnd));
9066 added += chunk.size;
9067 }
9068 relativeEnd -= partSize;
9069 relativeStart = 0;
9070 yield chunk;
9071 }
9072 }
9073}
9074var CHUNK_SIZE;
9075var init_blobHelpers = __esm({
9076 "node_modules/formdata-node/lib/esm/blobHelpers.js"() {

Callers 1

sliceMethod · 0.85

Calls 3

maxMethod · 0.45
minMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…