* Advances the iterator to the point where we find the line.
(expression: string | RegExp)
| 112 | * Advances the iterator to the point where we find the line. |
| 113 | */ |
| 114 | async skipTo(expression: string | RegExp) { |
| 115 | this.stopExpression = undefined; |
| 116 | do { |
| 117 | let line = this.lineBuffer.at(this.current); |
| 118 | while (line === undefined) { |
| 119 | await this.lineBuffer.changed; |
| 120 | line = this.lineBuffer.at(this.current); |
| 121 | if (this.lineBuffer.completed) { |
| 122 | return this; |
| 123 | } |
| 124 | } |
| 125 | this.advance(); |
| 126 | if ( |
| 127 | expression instanceof RegExp |
| 128 | ? expression.test(line) |
| 129 | : expression === line |
| 130 | ) { |
| 131 | return this; |
| 132 | } |
| 133 | } while (true); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * gets the current line, and advances the position. |