( evaluate: LazyArg<Duplex>, onError: (error: unknown) => E, options?: FromReadableOptions & FromWritableOptions )
| 109 | |
| 110 | /** @internal */ |
| 111 | export 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 */ |
| 138 | export const pipeThroughDuplex = dual< |
no test coverage detected
searching dependent graphs…