MCPcopy Create free account
hub / github.com/Effect-TS/effect / readChunk

Method readChunk

packages/platform/deno/src/DenoFileSystem.ts:222–244  ·  view source on GitHub ↗
(method: string, buffer: Uint8Array)

Source from the content-addressed store, hash-verified

220 }
221
222 private readChunk(method: string, buffer: Uint8Array) {
223 return Effect.suspend(() => {
224 const position = this.position
225 return Effect.map(
226 tryPromise(
227 method,
228 undefined,
229 async () => {
230 if (this.nativePosition !== position) {
231 this.file.seekSync(position, Deno.SeekMode.Start)
232 }
233 this.nativePosition = undefined
234 return await this.file.read(buffer)
235 }
236 ),
237 (bytesRead) => {
238 const sizeRead = FileSystem.Size(bytesRead ?? 0)
239 this.position = this.nativePosition = position + sizeRead
240 return sizeRead
241 }
242 )
243 })
244 }
245
246 read(buffer: Uint8Array) {
247 return this.readChunk("read", buffer)

Callers 2

readMethod · 0.95
readAllocMethod · 0.95

Calls 3

tryPromiseFunction · 0.70
readMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected