MCPcopy Index your code
hub / github.com/Effect-TS/effect / loop

Function loop

packages/platform/src/internal/fileSystem.ts:211–233  ·  view source on GitHub ↗
(
    totalBytesRead: bigint
  )

Source from the content-addressed store, hash-verified

209 const chunkSize = Size(chunkSize_)
210
211 function loop(
212 totalBytesRead: bigint
213 ): Channel.Channel<Chunk.Chunk<Uint8Array>, unknown, Error.PlatformError, unknown, void, unknown> {
214 if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) {
215 return Channel.void
216 }
217
218 const toRead = bytesToRead !== undefined && (bytesToRead - totalBytesRead) < chunkSize
219 ? bytesToRead - totalBytesRead
220 : chunkSize
221
222 return Channel.flatMap(
223 file.readAlloc(toRead),
224 Option.match({
225 onNone: () => Channel.void,
226 onSome: (buf) =>
227 Channel.flatMap(
228 Channel.write(Chunk.of(buf)),
229 (_) => loop(totalBytesRead + BigInt(buf.length))
230 )
231 })
232 )
233 }
234
235 return Stream.bufferChunks(
236 Stream.fromChannel(loop(BigInt(0))),

Callers 1

streamFunction · 0.70

Calls 3

readAllocMethod · 0.80
writeMethod · 0.65
ofMethod · 0.65

Tested by

no test coverage detected