(chunk: string)
| 60 | } |
| 61 | |
| 62 | feed(chunk: string): void { |
| 63 | this.incomplete += chunk |
| 64 | |
| 65 | const lastCompleteIndex = this.incomplete.lastIndexOf('\n\n') |
| 66 | |
| 67 | if (lastCompleteIndex === -1) { |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | const completes = this.incomplete.slice(0, lastCompleteIndex).split(/\n\n/) |
| 72 | this.incomplete = this.incomplete.slice(lastCompleteIndex + 2) |
| 73 | |
| 74 | for (const encoded of completes) { |
| 75 | const message = decodeEventMessage(`${encoded}\n\n`) |
| 76 | |
| 77 | if (this.options.onEvent) { |
| 78 | this.options.onEvent(message) |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | end(): void { |
| 84 | if (this.incomplete) { |
no test coverage detected