Skip to content

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 to fsync, called by fflush() and exit())
  • When the buffer exceeds 4096 bytes (safety valve)

(chunk) => void

Called with each decoded chunk of output.

BufferedTTYOutput

A BufferedTTYOutput.

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.

const out = createBufferedOutput(chunk => proc.stdout.write(chunk))
installTTYBridge(module, { input, output: out })

installTTYBridge