Function
updateLineEndingFlagsFromBytes
(
flags: LineEndingFlags,
chunk: Buffer,
prevWasCr: boolean,
)
Source from the content-addressed store, hash-verified
| 788 | } |
| 789 | |
| 790 | function updateLineEndingFlagsFromBytes( |
| 791 | flags: LineEndingFlags, |
| 792 | chunk: Buffer, |
| 793 | prevWasCr: boolean, |
| 794 | ): boolean { |
| 795 | for (let i = 0; i < chunk.length; i += 1) { |
| 796 | const byte = chunk[i]; |
| 797 | if (byte === undefined) continue; |
| 798 | if (byte === 0x0d) { |
| 799 | if (prevWasCr) flags.hasLoneCr = true; |
| 800 | prevWasCr = true; |
| 801 | } else if (byte === 0x0a) { |
| 802 | if (prevWasCr) { |
| 803 | flags.hasCrLf = true; |
| 804 | } else { |
| 805 | flags.hasLf = true; |
| 806 | } |
| 807 | prevWasCr = false; |
| 808 | } else { |
| 809 | if (prevWasCr) flags.hasLoneCr = true; |
| 810 | prevWasCr = false; |
| 811 | } |
| 812 | } |
| 813 | return prevWasCr; |
| 814 | } |
| 815 | |
| 816 | function createUtf8Validator(): { write(chunk: Buffer): void; end(): void } { |
| 817 | let needed = 0; |
Tested by
no test coverage detected