(data: Uint8Array)
| 128 | }; |
| 129 | |
| 130 | const assertLikelyUtf8 = (data: Uint8Array): void => { |
| 131 | if (data.length <= FULL_UTF8_VALIDATE_LIMIT) { |
| 132 | new TextDecoder("utf-8", { fatal: true }).decode(data); |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | const decoder = new TextDecoder("utf-8", { fatal: true }); |
| 137 | for (const [start, end] of createSampleRanges(data)) { |
| 138 | decoder.decode(data.subarray(start, end)); |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | const decodeMostlyUtf8 = (data: Uint8Array): string | null => { |
| 143 | const decoded = new TextDecoder("utf-8").decode(data); |
no test coverage detected