MCPcopy
hub / github.com/Effect-TS/effect / fromDuplex

Function fromDuplex

packages/platform-node-shared/src/internal/stream.ts:111–135  ·  view source on GitHub ↗
(
  evaluate: LazyArg<Duplex>,
  onError: (error: unknown) => E,
  options?: FromReadableOptions & FromWritableOptions
)

Source from the content-addressed store, hash-verified

109
110/** @internal */
111export const fromDuplex = <IE, E, I = string | Uint8Array<ArrayBufferLike>, O = Uint8Array<ArrayBufferLike>>(
112 evaluate: LazyArg<Duplex>,
113 onError: (error: unknown) => E,
114 options?: FromReadableOptions & FromWritableOptions
115): Channel.Channel<
116 Chunk.Chunk<O>,
117 Chunk.Chunk<I>,
118 IE | E,
119 IE
120> =>
121 Channel.suspend(() => {
122 const duplex = evaluate()
123 if (!duplex.readable) {
124 return Channel.void
125 }
126 const exit = MutableRef.make<Exit.Exit<void, IE | E> | undefined>(undefined)
127 return Channel.embedInput(
128 unsafeReadableRead<O, IE | E>(duplex, onError, exit, options),
129 writeInput<IE, I>(
130 duplex,
131 (cause) => Effect.sync(() => MutableRef.set(exit, Exit.failCause(cause))),
132 options
133 )
134 )
135 })
136
137/** @internal */
138export const pipeThroughDuplex = dual<

Callers 1

stream.tsFile · 0.70

Calls 6

unsafeReadableReadFunction · 0.85
writeInputFunction · 0.85
syncMethod · 0.80
failCauseMethod · 0.80
makeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected