(
options: {
readonly evaluate: LazyArg<Writable | NodeJS.WritableStream>
readonly onError: (error: unknown) => E
readonly endOnDone?: boolean | undefined
readonly encoding?: BufferEncoding | undefined
}
)
| 52 | * @since 4.0.0 |
| 53 | */ |
| 54 | export const fromWritableChannel = <IE, E, A = Uint8Array | string>( |
| 55 | options: { |
| 56 | readonly evaluate: LazyArg<Writable | NodeJS.WritableStream> |
| 57 | readonly onError: (error: unknown) => E |
| 58 | readonly endOnDone?: boolean | undefined |
| 59 | readonly encoding?: BufferEncoding | undefined |
| 60 | } |
| 61 | ): Channel.Channel<never, IE | E, void, NonEmptyReadonlyArray<A>, IE> => |
| 62 | Channel.fromTransform((pull: Pull.Pull<NonEmptyReadonlyArray<A>, IE, unknown>) => { |
| 63 | const writable = options.evaluate() as Writable |
| 64 | const write = pullIntoWritable({ ...options, writable, pull }) |
| 65 | return Effect.succeed( |
| 66 | options.endOnDone === false |
| 67 | ? write |
| 68 | : Effect.onError(write, (cause) => Pull.isDoneCause(cause) ? Effect.void : releaseWritable(writable)) |
| 69 | ) |
| 70 | }) |
| 71 | |
| 72 | // Destroy the writable and wait for destruction to settle, keeping any |
| 73 | // destruction error handled. |
no test coverage detected