import { ShutdownAwareTransformStream } from "https://deno.land/x/shutdown_aware_transform_stream@1.0.0/mod.ts";
A TransformStream
that allows its Transformer to be notified when the
stream has shutdown, either due to an error or from end-of-input.
The standard TransformStream
does not support notifying its Transformer
if the stream encounters an error.
To be notified of stream shutdown, either provide a close()
method on the
Transformer object, or register a listener on the Controller's signal
property (an AbortSignal
) in the Transformer's start()
method:
new ShutdownAwareTransformStream({
transformer: {
start(controller) {
controller.signal.addEventListener(
"abort",
() => console.log("stream aborted"),
);
},
close() {
console.log("stream has shutdown");
},
transform(chunk, controller) {
// ...
},
},
});
Constructors
new
ShutdownAwareTransformStream(options?: ShutdownAwareTransformStreamOptions<I, O>)Note that arguments are passed as an object rather than individually
(unlike a standard TransformStream
).
Properties
readonly
readable: ReadableStream<O>readonly
writable: WritableStream<I>