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

Function setupInput

packages/platform/node-shared/src/NodeChildProcessSpawner.ts:408–431  ·  view source on GitHub ↗
(
      fd: number,
      nodeStream: SpawnedProcess["stdio"][number],
      stream: Stream.Stream<Uint8Array, PlatformError.PlatformError> | undefined
    )

Source from the content-addressed store, hash-verified

406 const outputStreams = new Map<number, Stream.Stream<Uint8Array, PlatformError.PlatformError>>()
407
408 const setupInput = (
409 fd: number,
410 nodeStream: SpawnedProcess["stdio"][number],
411 stream: Stream.Stream<Uint8Array, PlatformError.PlatformError> | undefined
412 ) =>
413 Effect.suspend(() => {
414 let sink: Sink.Sink<void, Uint8Array, never, PlatformError.PlatformError> = Sink.drain
415 if (nodeStream && "write" in nodeStream) {
416 handleInputErrors(nodeStream)
417 sink = NodeSink.fromWritable({
418 evaluate: () => nodeStream,
419 onError: (error) => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)
420 })
421 }
422
423 if (stream) {
424 return Effect.map(runInputStream(stream, sink, inputFailure), () => {
425 inputSinks.set(fd, sink)
426 })
427 }
428
429 inputSinks.set(fd, sink)
430 return Effect.void
431 })
432
433 const setupOutput = (
434 fd: number,

Callers 1

Calls 6

handleInputErrorsFunction · 0.85
runInputStreamFunction · 0.85
toPlatformErrorFunction · 0.70
toErrorFunction · 0.70
setMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected