Live video on the AT Protocol
1import readline from "node:readline";
2
3const rl = readline.createInterface({
4 input: process.stdin,
5 output: process.stdout,
6 terminal: false,
7});
8
9let last;
10
11rl.on("line", (line) => {
12 if (line.startsWith("goroutine")) {
13 if (last) {
14 console.log(JSON.stringify(last));
15 }
16 last = {
17 goroutine: line,
18 stack: [`\n${line}`],
19 };
20 } else {
21 last.stack.push(line);
22 }
23});
24
25rl.on("close", () => {
26 if (last) {
27 console.log(JSON.stringify(last));
28 }
29});