()
| 135 | // Regression test: consumers should tolerate sources that yield raw |
| 136 | // Uint8Array or string values instead of Uint8Array[] batches. |
| 137 | async function testConsumersNonArrayBatch() { |
| 138 | const encoder = new TextEncoder(); |
| 139 | |
| 140 | // Source yields raw Uint8Array, not wrapped in an array |
| 141 | async function* rawSource() { |
| 142 | yield encoder.encode('hello'); |
| 143 | yield encoder.encode(' world'); |
| 144 | } |
| 145 | const result = await text(rawSource()); |
| 146 | assert.strictEqual(result, 'hello world'); |
| 147 | |
| 148 | // bytes() with raw chunks |
| 149 | async function* rawSource2() { |
| 150 | yield encoder.encode('ab'); |
| 151 | } |
| 152 | const data = await bytes(rawSource2()); |
| 153 | assert.strictEqual(data.length, 2); |
| 154 | assert.strictEqual(data[0], 97); // 'a' |
| 155 | assert.strictEqual(data[1], 98); // 'b' |
| 156 | |
| 157 | // array() with raw chunks |
| 158 | async function* rawSource3() { |
| 159 | yield encoder.encode('x'); |
| 160 | yield encoder.encode('y'); |
| 161 | } |
| 162 | const arr = await array(rawSource3()); |
| 163 | assert.strictEqual(arr.length, 2); |
| 164 | } |
| 165 | |
| 166 | async function testConsumersNonArrayBatchSync() { |
| 167 | const encoder = new TextEncoder(); |
no test coverage detected
searching dependent graphs…