| 721 | export const kebabToSnake = (self: string): string => self.replace(/-/g, "_") |
| 722 | |
| 723 | class LinesIterator implements IterableIterator<string> { |
| 724 | private index: number |
| 725 | private readonly length: number |
| 726 | |
| 727 | constructor(readonly s: string, readonly stripped: boolean = false) { |
| 728 | this.index = 0 |
| 729 | this.length = s.length |
| 730 | } |
| 731 | |
| 732 | next(): IteratorResult<string> { |
| 733 | if (this.done) { |
| 734 | return { done: true, value: undefined } |
| 735 | } |
| 736 | const start = this.index |
| 737 | while (!this.done && !isLineBreak(this.s[this.index]!)) { |
| 738 | this.index = this.index + 1 |
| 739 | } |
| 740 | let end = this.index |
| 741 | if (!this.done) { |
| 742 | const char = this.s[this.index]! |
| 743 | this.index = this.index + 1 |
| 744 | if (!this.done && isLineBreak2(char, this.s[this.index]!)) { |
| 745 | this.index = this.index + 1 |
| 746 | } |
| 747 | if (!this.stripped) { |
| 748 | end = this.index |
| 749 | } |
| 750 | } |
| 751 | return { done: false, value: this.s.substring(start, end) } |
| 752 | } |
| 753 | |
| 754 | [Symbol.iterator](): IterableIterator<string> { |
| 755 | return new LinesIterator(this.s, this.stripped) |
| 756 | } |
| 757 | |
| 758 | private get done(): boolean { |
| 759 | return this.index >= this.length |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | /** |
| 764 | * Test if the provided character is a line break character (i.e. either `"\r"` |
nothing calls this directly
no outgoing calls
no test coverage detected