createBufferedOutput
createBufferedOutput(
sink):BufferedTTYOutput
Defined in: packages/runtime/src/wasm/tty-bridge.ts:306
Create a buffered TTY output that batches putChar calls.
Flushes on three conditions:
- At the end of the current synchronous WASM burst (via
queueMicrotask) - On explicit
flush()(wired tofsync, called byfflush()andexit()) - When the buffer exceeds 4096 bytes (safety valve)
Parameters
Section titled “Parameters”(chunk) => void
Called with each decoded chunk of output.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Raw bytes are accumulated and decoded at flush time so multi-byte
UTF-8 sequences (e.g. box-drawing chars U+2500 = E2 94 80) are
decoded correctly instead of being emitted per-byte as mojibake.
Example
Section titled “Example”const out = createBufferedOutput(chunk => proc.stdout.write(chunk))installTTYBridge(module, { input, output: out })