True if `buf` decodes as strict UTF-8 (no invalid byte sequences).
(buf: Buffer)
| 201 | |
| 202 | /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */ |
| 203 | function isValidUtf8(buf: Buffer): boolean { |
| 204 | try { |
| 205 | new TextDecoder('utf-8', { fatal: true }).decode(buf); |
| 206 | return true; |
| 207 | } catch { |
| 208 | return false; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Read a `.gitignore` and return patterns safe to hand to the `ignore` matcher — |
no outgoing calls
no test coverage detected