Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-ts latest

Program.stream

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

Source and package
Qualified name
Program.stream
Module
program
Declared in
Program
Package
libtmux
Source
packages/libtmux/src/program.ts
stream( options?: ProgramStreamOptions, ): AsyncGenerator<string, void, undefined>

Description#

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 of kind cancelled. Either way the program runs on.

Examples#

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"
Esc

Type to search.

Reference previewOpen reference