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