UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

30 lines (29 loc) 785 B
import { t as createWindowsOutputDecoder } from "./windows-encoding-Cl7_e1FK.js"; //#region src/process/decoded-output.ts function onDecodedOutput(stream, listener, onRaw) { const decoder = createWindowsOutputDecoder(); const emit = (text) => { if (text) listener(text); }; let flushed = false; const flush = () => { if (flushed) return; flushed = true; emit(decoder.flush()); }; const onData = (chunk) => { onRaw?.(typeof chunk === "string" ? Buffer.from(chunk) : chunk); emit(decoder.decode(chunk)); }; stream.on("data", onData); stream.once("end", flush); stream.once("close", flush); return () => { flushed = true; stream.off("data", onData); stream.off("end", flush); stream.off("close", flush); }; } //#endregion export { onDecodedOutput as t };