MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isValidUtf8

Function isValidUtf8

src/extraction/index.ts:218–225  ·  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

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

Callers 1

readGitignorePatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected