* Process transform result (sync). * @yields {Uint8Array[]}
(result)
| 230 | * @yields {Uint8Array[]} |
| 231 | */ |
| 232 | function* processTransformResultSync(result) { |
| 233 | if (result === null) { |
| 234 | return; |
| 235 | } |
| 236 | // Single Uint8Array -> wrap as batch |
| 237 | if (isUint8Array(result)) { |
| 238 | yield [result]; |
| 239 | return; |
| 240 | } |
| 241 | // String -> UTF-8 encode and wrap as batch |
| 242 | if (typeof result === 'string') { |
| 243 | yield [toUint8Array(result)]; |
| 244 | return; |
| 245 | } |
| 246 | // ArrayBuffer / ArrayBufferView -> convert and wrap |
| 247 | if (isAnyArrayBuffer(result)) { |
| 248 | yield [new Uint8Array(result)]; |
| 249 | return; |
| 250 | } |
| 251 | if (ArrayBufferIsView(result)) { |
| 252 | yield [arrayBufferViewToUint8Array(result)]; |
| 253 | return; |
| 254 | } |
| 255 | // Uint8Array[] batch |
| 256 | if (isUint8ArrayBatch(result)) { |
| 257 | if (result.length > 0) { |
| 258 | yield result; |
| 259 | } |
| 260 | return; |
| 261 | } |
| 262 | // Iterable or Generator |
| 263 | if (isSyncIterable(result)) { |
| 264 | const batch = []; |
| 265 | for (const item of result) { |
| 266 | for (const chunk of flattenTransformYieldSync(item)) { |
| 267 | ArrayPrototypePush(batch, chunk); |
| 268 | } |
| 269 | } |
| 270 | if (batch.length > 0) { |
| 271 | yield batch; |
| 272 | } |
| 273 | return; |
| 274 | } |
| 275 | throw new ERR_INVALID_ARG_TYPE( |
| 276 | 'result', |
| 277 | ['null', 'Uint8Array', 'string', 'ArrayBuffer', |
| 278 | 'ArrayBufferView', 'Array', 'Iterable'], |
| 279 | result); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Append normalized transform result batches to an array (sync). |
no test coverage detected
searching dependent graphs…