# program.Program.stream

- **Module:** program
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/ad09eaef7ffff40f510989ee0695852c44a31576/packages/libtmux/src/program.ts#L108
- **Page:** https://libtmux.org/en/ts/latest/reference/program-program-stream/

```
stream(
  options?: ProgramStreamOptions,
): AsyncGenerator<string, void, undefined>
```

Everything the program writes, as UTF-8 text in the order it was written, until it exits and its last write has arrived.

Needs `stream: true` at spawn. The text is the terminal's: line ends are
`\r\n`, escape sequences are left in, and bytes that are not UTF-8 become
U+FFFD. Each call reads from the start; leaving the loop early stops it,
and so does `signal`, with [`TmuxTransportError`](/en/ts/latest/reference/errors-tmuxtransporterror/) of kind `cancelled`.
Either way the program runs on.

## Examples

```ts
await using program = await server.spawn(["seq", "1", "3"], { stream: true });
let text = "";
for await (const chunk of program.stream()) text += chunk;
text; // "1\r\n2\r\n3\r\n"
```

## Parameters

- `options?` (`ProgramStreamOptions`)
