# collapseStream

> Folds every `[data-stream-collapse]` disclosure in `root` that comes before `block`, or all of them without one, marking each `data-stream-collapsed`.

```ts
import { collapseStream } from "@sdxc/ui/chat";
```

Folds every `[data-stream-collapse]` disclosure in `root` that comes before `block`, or all
of them without one, marking each `data-stream-collapsed`. A reply shown without a replay
calls it with no block, so it reads the same as one that streamed.

## Signature

```ts
collapseStream(root: HTMLElement, block?: Element): void
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `root` | `HTMLElement` | The reply. |
| `block?` | `Element` | The block the replay is about to show. |

## Examples

```tsx
collapseStream(document.getElementById("reply-7")!)
```

## Used with it

The events, constants and types its module publishes, each imported from `@sdxc/ui/chat` too.

### StreamRevealOptions

Options for revealStream.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `interval?` | `number` | Milliseconds between ticks. @default 32 |
| `onEnd?` | `(end: StreamRevealEnd) => void` | Called once, when the whole reply has shown or StreamReveal.stop ran. |
| `signal?` | `AbortSignal` | Stops the reveal where it is when aborted, as StreamReveal.stop does. |

### StreamReveal

A running reveal.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `stop` | `void` | Freezes the reply at what has shown; the rest of it stays out of the page. |

### StreamRevealEnd

How a reveal finished.

#### Signature

```ts
type StreamRevealEnd = "done" | "stopped"
```

One of `"done"`, `"stopped"`.
