(resource: string, decoder: TextDecoder, bytes?: Uint8Array)
| 151 | return nonPrintable / bytes.length > 0.3 |
| 152 | } |
| 153 | const 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 | }) |
| 161 | const decodeChunk = (resource: string, decoder: TextDecoder, bytes: Uint8Array) => |
| 162 | bytes.includes(0) ? Effect.fail(new BinaryFileError({ resource })) : decodeUtf8(resource, decoder, bytes) |
| 163 |
no outgoing calls
no test coverage detected