* Flatten transform yield to Uint8Array chunks (async).
( value: TransformYield | AsyncIterable<TransformYield> )
| 150 | /** |
| 151 | * Flatten transform yield to Uint8Array chunks (async). |
| 152 | */ |
| 153 | async function* flattenTransformYieldAsync( |
| 154 | value: TransformYield | AsyncIterable<TransformYield> |
| 155 | ): AsyncGenerator<Uint8Array> { |
| 156 | if (value instanceof Uint8Array) { |
| 157 | yield value; |
| 158 | return; |
| 159 | } |
| 160 | if (typeof value === 'string') { |
| 161 | yield encoder.encode(value); |
| 162 | return; |
| 163 | } |
| 164 | // Check for async iterable first |
| 165 | if (isAsyncIterable(value)) { |
| 166 | for await (const item of value) { |
| 167 | yield* flattenTransformYieldAsync(item as TransformYield); |
| 168 | } |
| 169 | return; |
| 170 | } |
| 171 | // Must be sync Iterable<TransformYield> |
| 172 | if (isSyncIterable(value)) { |
| 173 | for (const item of value) { |
| 174 | yield* flattenTransformYieldAsync(item as TransformYield); |
| 175 | } |
| 176 | return; |
| 177 | } |
| 178 | throw new TypeError(`Invalid transform yield type: ${typeof value}`); |
| 179 | } |
| 180 | |
| 181 | /** |
no test coverage detected