Skip to content

@jsvision/ui / terminalWriter

Function: terminalWriter()

terminalWriter(term): (s) => void

Defined in: ui/src/terminal/terminal.ts:135

Wrap a Terminal as a plain (text) => void sink, so anything that writes strings to a callback — a logger, a subprocess stdout handler, a progress reporter — can stream into the view.

Parameters

term

Terminal

The terminal view to append into.

Returns

A function that writes each string into term.

(s) => void

Example

ts
import { Terminal, terminalWriter } from '@jsvision/ui';

const log = new Terminal();
const write = terminalWriter(log);

// Feed it from anywhere that emits text lines.
write('server listening on :8080\n');
childProcess.stdout.on('data', (chunk) => write(String(chunk)));