(options: {
readonly evaluate: LazyArg<TransformStream<I, O>>
readonly onError: (error: unknown) => E
readonly closeOnDone?: boolean | undefined
readonly releaseLockOnEnd?: boolean | undefined
})
| 1905 | * @since 4.0.0 |
| 1906 | */ |
| 1907 | export const fromTransformStream = <IE, I, O, E>(options: { |
| 1908 | readonly evaluate: LazyArg<TransformStream<I, O>> |
| 1909 | readonly onError: (error: unknown) => E |
| 1910 | readonly closeOnDone?: boolean | undefined |
| 1911 | readonly releaseLockOnEnd?: boolean | undefined |
| 1912 | }): Channel<Arr.NonEmptyReadonlyArray<O>, IE | E, void, Arr.NonEmptyReadonlyArray<I>, IE> => |
| 1913 | fromTransform((upstream, scope) => { |
| 1914 | const transform = options.evaluate() |
| 1915 | const exit = MutableRef.make<Exit.Exit<never, IE | E | Cause.Done> | undefined>(undefined) |
| 1916 | return pullIntoWritableStream({ |
| 1917 | pull: upstream, |
| 1918 | writable: transform.writable, |
| 1919 | onError: options.onError, |
| 1920 | closeOnDone: options.closeOnDone, |
| 1921 | // Aborting errors the readable, so record the failure first. Otherwise a |
| 1922 | // pending read reports the abort reason instead. |
| 1923 | onAbort: (cause) => { |
| 1924 | exit.current = Exit.failCause(cause) |
| 1925 | } |
| 1926 | }).pipe( |
| 1927 | Effect.catchCause((cause) => { |
| 1928 | if (!Pull.isDoneCause(cause)) { |
| 1929 | exit.current = Exit.failCause(cause as Cause.Cause<IE | E | Cause.Done>) |
| 1930 | } |
| 1931 | return Effect.void |
| 1932 | }), |
| 1933 | Effect.forkIn(scope), |
| 1934 | Effect.flatMap(() => |
| 1935 | readableStreamToPullUnsafe({ |
| 1936 | scope, |
| 1937 | exit, |
| 1938 | readable: transform.readable, |
| 1939 | onError: options.onError, |
| 1940 | releaseLockOnEnd: options.releaseLockOnEnd |
| 1941 | }) |
| 1942 | ) |
| 1943 | ) |
| 1944 | }) |
| 1945 | |
| 1946 | const readableStreamToPullUnsafe = <A, E, E2 = never>(options: { |
| 1947 | readonly scope: Scope.Scope |
nothing calls this directly
no test coverage detected