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

Function decodeUtf8

packages/core/src/tool/read-filesystem.ts:153–160  ·  view source on GitHub ↗
(resource: string, decoder: TextDecoder, bytes?: Uint8Array)

Source from the content-addressed store, hash-verified

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 }),
156 catch: (error) => {
157 if (error instanceof TypeError) return new MalformedUtf8Error({ resource })
158 throw error
159 },
160 })
161const decodeChunk = (resource: string, decoder: TextDecoder, bytes: Uint8Array) =>
162 bytes.includes(0) ? Effect.fail(new BinaryFileError({ resource })) : decodeUtf8(resource, decoder, bytes)
163

Callers 2

decodeChunkFunction · 0.70
read-filesystem.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected