buf.indexOf bounded to [0, end) without allocating a view.
(buf: Buffer, needle: Buffer, end: number)
| 146 | |
| 147 | /** buf.indexOf bounded to [0, end) without allocating a view. */ |
| 148 | function indexOfWithin(buf: Buffer, needle: Buffer, end: number): number { |
| 149 | const at = buf.indexOf(needle) |
| 150 | return at === -1 || at + needle.length > end ? -1 : at |
| 151 | } |
| 152 | |
| 153 | function countNewlines(buf: Buffer, start: number, end: number): number { |
| 154 | let n = 0 |