Reference

StreamingBufferSink

A streaming-flavored buffer sink used by `renderToReadableStream`. Coalesces successive `append(chunk)` calls into a single byte buffer, then hands the buffer to a consumer callback either on demand (`flush()`) or automatically once the accumulated UTF-8 byte length crosses a threshold. The contract: - Each call to `flush()` (or an auto-flush triggered from within `append`) delivers **exactly one** non-empty byte buffer to the consumer. Empty buffers are never delivered — callers do not need to filter them out. - The delivered buffer is exclusively owned by the consumer; the sink will not mutate it afterwards. Internally we allocate a fresh backing buffer per epoch, so handing off a `subarray` view is safe with no copy. Issue 084: motivated by the streaming SSR throughput gap to marko-run (mreact was at 0.66x marko's ops/sec because the previous implementation paid a `TextEncoder.encode` + Web Streams `controller.enqueue` round-trip per `sink.append()` call).

Signature

interface StreamingBufferSink

Members

function append(chunk: string): void
function flush(): void
function size(): number