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

Function readFileInChunks

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

Source from the content-addressed store, hash-verified

734 * Reads a file in chunks to avoid loading entire file into memory.
735 */
736export async function* readFileInChunks(
737 filePath: string,
738 chunkSize: number = 64 * 1024
739): AsyncGenerator<string, void, undefined> {
740 const fs = await import('fs');
741
742 const fd = fs.openSync(filePath, 'r');
743 const buffer = Buffer.alloc(chunkSize);
744
745 try {
746 let bytesRead: number;
747 while ((bytesRead = fs.readSync(fd, buffer, 0, chunkSize, null)) > 0) {
748 yield buffer.toString('utf-8', 0, bytesRead);
749 }
750 } finally {
751 fs.closeSync(fd);
752 }
753}
754
755/**
756 * Debounce a function

Callers

nothing calls this directly

Calls 1

openSyncMethod · 0.45

Tested by

no test coverage detected