* Flatten transform yield to Uint8Array chunks (async). * @yields {Uint8Array}
(value)
| 188 | * @yields {Uint8Array} |
| 189 | */ |
| 190 | async function* flattenTransformYieldAsync(value) { |
| 191 | if (isUint8Array(value)) { |
| 192 | yield value; |
| 193 | return; |
| 194 | } |
| 195 | if (typeof value === 'string') { |
| 196 | yield toUint8Array(value); |
| 197 | return; |
| 198 | } |
| 199 | if (isAnyArrayBuffer(value)) { |
| 200 | yield new Uint8Array(value); |
| 201 | return; |
| 202 | } |
| 203 | if (ArrayBufferIsView(value)) { |
| 204 | yield arrayBufferViewToUint8Array(value); |
| 205 | return; |
| 206 | } |
| 207 | // Check for async iterable first |
| 208 | if (isAsyncIterable(value)) { |
| 209 | for await (const item of value) { |
| 210 | yield* flattenTransformYieldAsync(item); |
| 211 | } |
| 212 | return; |
| 213 | } |
| 214 | // Must be sync Iterable<TransformYield>, no nested async iterables |
| 215 | if (isSyncIterable(value)) { |
| 216 | for (const item of value) { |
| 217 | yield* flattenTransformYieldSync(item); |
| 218 | } |
| 219 | return; |
| 220 | } |
| 221 | throw new ERR_INVALID_ARG_TYPE( |
| 222 | 'value', |
| 223 | ['Uint8Array', 'string', 'ArrayBuffer', 'ArrayBufferView', |
| 224 | 'Iterable', 'AsyncIterable'], |
| 225 | value); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Process transform result (sync). |
no test coverage detected
searching dependent graphs…