(text: string)
| 34 | } |
| 35 | |
| 36 | function* readTextLines(text: string): Generator<string> { |
| 37 | let line = ""; |
| 38 | for (let i = 0; i < text.length; i += 1) { |
| 39 | const char = text[i]; |
| 40 | switch (char) { |
| 41 | case "\n": |
| 42 | yield line; |
| 43 | line = ""; |
| 44 | break; |
| 45 | case "\r": |
| 46 | yield line; |
| 47 | line = ""; |
| 48 | if (text[i + 1] === "\n") i += 1; |
| 49 | break; |
| 50 | default: |
| 51 | line += char; |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | yield line; |
| 56 | } |
| 57 | |
| 58 | /** Options for {@linkcode parse}. */ |
| 59 | export interface ParseOptions { |