MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readFileInChunks

Function readFileInChunks

src/utils.ts:762–779  ·  view source on GitHub ↗
(
  filePath: string,
  chunkSize: number = 64 * 1024
)

Source from the content-addressed store, hash-verified

760 * Reads a file in chunks to avoid loading entire file into memory.
761 */
762export async function* readFileInChunks(
763 filePath: string,
764 chunkSize: number = 64 * 1024
765): AsyncGenerator<string, void, undefined> {
766 const fs = await import('fs');
767
768 const fd = fs.openSync(filePath, 'r');
769 const buffer = Buffer.alloc(chunkSize);
770
771 try {
772 let bytesRead: number;
773 while ((bytesRead = fs.readSync(fd, buffer, 0, chunkSize, null)) > 0) {
774 yield buffer.toString('utf-8', 0, bytesRead);
775 }
776 } finally {
777 fs.closeSync(fd);
778 }
779}
780
781/**
782 * Debounce a function

Callers

nothing calls this directly

Calls 1

openSyncMethod · 0.45

Tested by

no test coverage detected