(raw)
| 105 | // Readable into Uint8Array values. Returns the normalized batch, |
| 106 | // or null if normalization produced no output. |
| 107 | async function normalizeBatch(raw) { |
| 108 | const batch = []; |
| 109 | for (let i = 0; i < raw.length; i++) { |
| 110 | const value = raw[i]; |
| 111 | if (isUint8Array(value)) { |
| 112 | ArrayPrototypePush(batch, value); |
| 113 | } else { |
| 114 | // normalizeAsyncValue may await for async protocols (e.g. |
| 115 | // toAsyncStreamable on yielded objects). Stream events during |
| 116 | // the suspension are queued, not lost -- errors will surface |
| 117 | // on the next loop iteration after this yield completes. |
| 118 | for await (const normalized of normalizeAsyncValue(value)) { |
| 119 | ArrayPrototypePush(batch, normalized); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | return batch.length > 0 ? batch : null; |
| 124 | } |
| 125 | |
| 126 | // Batched async iterator for Readable streams. Same mechanism as |
| 127 | // createAsyncIterator (same event setup, same stream.read() to |
nothing calls this directly
no test coverage detected