MCPcopy Index your code
hub / github.com/anomalyco/opencode / binary

Function binary

packages/core/src/tool/read-filesystem.ts:143–152  ·  view source on GitHub ↗
(resource: string, bytes: Uint8Array)

Source from the content-addressed store, hash-verified

141 return "image/webp"
142}
143const binary = (resource: string, bytes: Uint8Array) => {
144 if (extensions.has(path.extname(resource).toLowerCase())) return true
145 if (bytes.length === 0) return false
146 let nonPrintable = 0
147 for (const byte of bytes) {
148 if (byte === 0) return true
149 if (byte < 9 || (byte > 13 && byte < 32)) nonPrintable++
150 }
151 return nonPrintable / bytes.length > 0.3
152}
153const decodeUtf8 = (resource: string, decoder: TextDecoder, bytes?: Uint8Array) =>
154 Effect.try({
155 try: () => decoder.decode(bytes, { stream: bytes !== undefined }),

Callers 1

read-filesystem.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected