* Heuristic binary detection: a NUL byte in the first 8 KB marks the file as * binary, matching `git diff` / `git grep` semantics.
(buf: Buffer)
| 107 | * binary, matching `git diff` / `git grep` semantics. |
| 108 | */ |
| 109 | function isBinaryBuffer(buf: Buffer): boolean { |
| 110 | const len = Math.min(buf.length, BINARY_SNIFF_BYTES) |
| 111 | for (let i = 0; i < len; i++) { |
| 112 | if (buf[i] === 0) return true |
| 113 | } |
| 114 | return false |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Parses a comma-separated extension filter into a normalized set (leading dot, |