| 1367 | export const kebabToSnake = (self: string): string => self.replace(/-/g, "_") |
| 1368 | |
| 1369 | class LinesIterator implements IterableIterator<string> { |
| 1370 | private index: number |
| 1371 | private readonly length: number |
| 1372 | readonly s: string |
| 1373 | readonly stripped: boolean |
| 1374 | |
| 1375 | constructor( |
| 1376 | s: string, |
| 1377 | stripped: boolean = false |
| 1378 | ) { |
| 1379 | this.s = s |
| 1380 | this.stripped = stripped |
| 1381 | this.index = 0 |
| 1382 | this.length = s.length |
| 1383 | } |
| 1384 | |
| 1385 | next(): IteratorResult<string> { |
| 1386 | if (this.done) { |
| 1387 | return { done: true, value: undefined } |
| 1388 | } |
| 1389 | const start = this.index |
| 1390 | while (!this.done && !isLineBreak(this.s[this.index]!)) { |
| 1391 | this.index = this.index + 1 |
| 1392 | } |
| 1393 | let end = this.index |
| 1394 | if (!this.done) { |
| 1395 | const char = this.s[this.index]! |
| 1396 | this.index = this.index + 1 |
| 1397 | if (!this.done && isLineBreak2(char, this.s[this.index]!)) { |
| 1398 | this.index = this.index + 1 |
| 1399 | } |
| 1400 | if (!this.stripped) { |
| 1401 | end = this.index |
| 1402 | } |
| 1403 | } |
| 1404 | return { done: false, value: this.s.substring(start, end) } |
| 1405 | } |
| 1406 | |
| 1407 | [Symbol.iterator](): IterableIterator<string> { |
| 1408 | return this |
| 1409 | } |
| 1410 | |
| 1411 | private get done(): boolean { |
| 1412 | return this.index >= this.length |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | /** |
| 1417 | * Checks whether the provided character is a line break character (i.e. either `"\r"` |
nothing calls this directly
no outgoing calls
no test coverage detected