Skip to content

@jsvision/ui / terminalWriter

Function: terminalWriter()

terminalWriter(term): (s) => void

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

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 { spawn } from 'node:child_process';
import { Terminal, terminalWriter } from '@jsvision/ui';

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

// Feed it from anywhere that emits text lines — here, a spawned subprocess.
write('server listening on :8080\n');
const child = spawn('node', ['--version']);
child.stdout.on('data', (chunk: Buffer) => write(String(chunk)));