True if `buf` decodes as strict UTF-8 (no invalid byte sequences).
(buf: Buffer)
| 216 | |
| 217 | /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */ |
| 218 | function isValidUtf8(buf: Buffer): boolean { |
| 219 | try { |
| 220 | new TextDecoder('utf-8', { fatal: true }).decode(buf); |
| 221 | return true; |
| 222 | } catch { |
| 223 | return false; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Read a `.gitignore` and return patterns safe to hand to the `ignore` matcher — |
no outgoing calls
no test coverage detected