(stop: (code: number) => boolean, plain = false)
| 830 | // `plain` reads a plain scalar, which also stops at a `:` that separates a key from its |
| 831 | // value and at the end of a line a comment ended. |
| 832 | private readUntil(stop: (code: number) => boolean, plain = false): string { |
| 833 | this.afterJsonNode = false |
| 834 | // Only text spanning lines needs pieces; most tokens are one slice of one line. |
| 835 | let pieces: Array<string> | undefined |
| 836 | let start = this.index |
| 837 | while (true) { |
| 838 | if (this.index === this.line.length) { |
| 839 | const piece = this.line.slice(start) |
| 840 | if (this.depth === 0 || (plain && this.comment) || !this.nextChunk(plain ? "plain" : "token")) { |
| 841 | return pieces === undefined ? piece : pieces.join("") + piece |
| 842 | } |
| 843 | ;(pieces ??= []).push(piece) |
| 844 | start = 0 |
| 845 | } |
| 846 | const code = this.line.charCodeAt(this.index) |
| 847 | if (stop(code) || (plain && code === 58 && this.isValueSeparator())) break |
| 848 | this.index++ |
| 849 | } |
| 850 | const piece = this.line.slice(start, this.index) |
| 851 | return pieces === undefined ? piece : pieces.join("") + piece |
| 852 | } |
| 853 | |
| 854 | // YAML 1.2.2 §7.3.3: in flow context, a `:` followed by white space, a line break or a flow |
| 855 | // indicator separates a key from its value. Any other `:` is part of a plain scalar. |
no test coverage detected