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

Method writeChunk

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

Source from the content-addressed store, hash-verified

273 }
274
275 private writeChunk(method: string, buffer: Uint8Array) {
276 return Effect.suspend(() => {
277 const position = this.position
278 return Effect.map(
279 tryPromise(
280 method,
281 undefined,
282 async () => {
283 if (!this.append && this.nativePosition !== position) {
284 this.file.seekSync(position, Deno.SeekMode.Start)
285 }
286 this.nativePosition = undefined
287 return await this.file.write(buffer)
288 }
289 ),
290 (bytesWritten) => {
291 const sizeWritten = FileSystem.Size(bytesWritten)
292 if (this.append) {
293 this.nativePosition = undefined
294 } else {
295 this.position = this.nativePosition = position + sizeWritten
296 }
297 return sizeWritten
298 }
299 )
300 })
301 }
302
303 write(buffer: Uint8Array) {
304 return this.writeChunk("write", buffer)

Callers 2

writeMethod · 0.95
writeAllChunkMethod · 0.95

Calls 3

tryPromiseFunction · 0.70
writeMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected