* Split `text` into an array of lines, including the trailing newline character (where present)
(text: string)
| 631 | * Split `text` into an array of lines, including the trailing newline character (where present) |
| 632 | */ |
| 633 | function splitLines(text: string): string[] { |
| 634 | const hasTrailingNl = text.endsWith('\n'); |
| 635 | const result = text.split('\n').map(line => line + '\n'); |
| 636 | if (hasTrailingNl) { |
| 637 | result.pop(); |
| 638 | } else { |
| 639 | result.push( |
| 640 | (result.pop() as string).slice(0, -1) |
| 641 | ); |
| 642 | } |
| 643 | return result; |
| 644 | } |
no outgoing calls
no test coverage detected