MCPcopy Create free account
hub / github.com/modelcontextprotocol/ext-apps / sliceToChunk

Function sliceToChunk

examples/pdf-server/server.ts:770–779  ·  view source on GitHub ↗

Slice a cached or freshly-fetched full body to the requested range.

(
    fullData: Uint8Array,
    offset: number,
    clampedByteCount: number,
  )

Source from the content-addressed store, hash-verified

768
769 /** Slice a cached or freshly-fetched full body to the requested range. */
770 function sliceToChunk(
771 fullData: Uint8Array,
772 offset: number,
773 clampedByteCount: number,
774 ): { data: Uint8Array; totalBytes: number } {
775 const totalBytes = fullData.length;
776 const start = Math.min(offset, totalBytes);
777 const end = Math.min(start + clampedByteCount, totalBytes);
778 return { data: fullData.slice(start, end), totalBytes };
779 }
780
781 async function readPdfRange(
782 url: string,

Callers 1

readPdfRangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…