AbortStream

import { AbortStream } from "jsr:@ende/streams/unstable-abort-stream";

class · experimental · deprecated

class AbortStream<T> extends TransformStream<T, T>

A transform stream that accepts a AbortSignal to easily abort a stream pipeThrough.

Deprecated.

Use readable.pipThrough's signal option instead.

Example: Usage

import { AbortStream } from "@ende/streams/unstable-abort-stream";
import { assertRejects } from "@ende/assert/rejects";

const controller = new AbortController();
controller.abort(new Error("STOP"));

await assertRejects(
  async function () {
    await new Response(
      (await Ende.open("./ende.json"))
        .readable
        .pipeThrough(new AbortStream(controller.signal)),
    )
      .bytes();
  },
  Error,
  "STOP",
);

Constructors

constructor

new AbortStream(signal: AbortSignal)

Constructs a new instance.

signal: AbortSignal

The AbortSignal.

Source