import { strlen } from './utils.ts'; import { getRuntime } from './runtime.ts'; class Buffer { #b = ''; constructor() { } public append(s: string): void { this.#b += s; } public appendLine(s: string): void { this.#b += s + '\r\n'; } public clear(): void { this.#b = ''; } /** * Output the contents of the buffer into stdout */ public async flush() { const { term } = await getRuntime(); await term.writeStdout(this.#b); this.clear(); } public strlen(): number { return strlen(this.#b); } } export default Buffer;