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

Function onFile

packages/effect/src/unstable/http/Multipart.ts:462–483  ·  view source on GitHub ↗
(info)

Source from the content-addressed store, hash-verified

460 partsBuffer.push(new FieldImpl(info.name, info.contentType, MP.decodeField(info, value)))
461 },
462 onFile(info) {
463 let chunks: Array<Uint8Array> = []
464 let finished = false
465 const pullChunks = Channel.fromPull(
466 Effect.succeed(Effect.suspend(function loop(): Pull.Pull<Arr.NonEmptyReadonlyArray<Uint8Array>> {
467 if (!Arr.isReadonlyArrayNonEmpty(chunks)) {
468 return finished ? Cause.done() : Effect.flatMap(pump, loop)
469 }
470 const chunk = chunks
471 chunks = []
472 return Effect.succeed(chunk)
473 }))
474 )
475 partsBuffer.push(new FileImpl(info, pullChunks))
476 return function(chunk) {
477 if (chunk === null) {
478 finished = true
479 } else {
480 chunks.push(chunk)
481 }
482 }
483 },
484 onError(error_) {
485 exit = Option.some(Exit.fail(convertError(error_)))
486 },

Callers

nothing calls this directly

Calls 3

pushMethod · 0.80
succeedMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected