MCPcopy
hub / github.com/colbymchenry/codegraph / isValidUtf8

Function isValidUtf8

src/extraction/index.ts:203–210  ·  view source on GitHub ↗

True if `buf` decodes as strict UTF-8 (no invalid byte sequences).

(buf: Buffer)

Source from the content-addressed store, hash-verified

201
202/** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */
203function 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 —

Callers 1

readGitignorePatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected