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

Method writeChunk

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

Source from the content-addressed store, hash-verified

307 }
308
309 private writeChunk(method: string, buffer: Uint8Array) {
310 return Effect.suspend(() => {
311 const position = this.position
312 return Effect.map(
313 tryPromise(
314 method,
315 undefined,
316 (signal) =>
317 this.native(signal, async () => {
318 if (!this.append && this.nativePosition !== position) {
319 this.file.seekSync(position, Deno.SeekMode.Start)
320 }
321 this.nativePosition = undefined
322 const bytesWritten = await this.file.write(buffer)
323 if (!this.append) {
324 this.nativePosition = position + BigInt(bytesWritten)
325 }
326 return bytesWritten
327 })
328 ),
329 (bytesWritten) => {
330 if (!this.append) {
331 this.position = position + BigInt(bytesWritten)
332 }
333 return bytesWritten
334 }
335 )
336 })
337 }
338
339 write(buffer: Uint8Array) {
340 return this.writeChunk("write", buffer)

Callers 2

writeMethod · 0.95
writeAllChunkMethod · 0.95

Calls 5

nativeMethod · 0.95
tryPromiseFunction · 0.70
writeMethod · 0.65
BigIntInterface · 0.50
mapMethod · 0.45

Tested by

no test coverage detected