(write: (line: string) => void)
| 57 | |
| 58 | /** Buffer chunked output into whole lines before handing them to `write`. */ |
| 59 | const makeLineSplitter = (write: (line: string) => void) => { |
| 60 | let buffer = ""; |
| 61 | return (text: string) => { |
| 62 | buffer += text; |
| 63 | const lines = buffer.split("\n"); |
| 64 | buffer = lines.pop() ?? ""; |
| 65 | for (const line of lines) { |
| 66 | if (line.trim().length > 0) write(line); |
| 67 | } |
| 68 | }; |
| 69 | }; |
| 70 | |
| 71 | export interface SidecarConnection { |
| 72 | readonly baseUrl: string; |