(source, transform, options)
| 646 | } |
| 647 | |
| 648 | async function* applyStatefulAsyncTransform(source, transform, options) { |
| 649 | const output = transform(withFlushAsync(source), options); |
| 650 | for await (const item of output) { |
| 651 | // Fast path: item is already a Uint8Array[] batch (e.g. compression transforms) |
| 652 | if (isUint8ArrayBatch(item)) { |
| 653 | if (item.length > 0) { |
| 654 | yield item; |
| 655 | } |
| 656 | continue; |
| 657 | } |
| 658 | // Fast path: single Uint8Array |
| 659 | if (isUint8Array(item)) { |
| 660 | yield [item]; |
| 661 | continue; |
| 662 | } |
| 663 | // Slow path: flatten arbitrary transform yield |
| 664 | const batch = []; |
| 665 | for await (const chunk of flattenTransformYieldAsync(item)) { |
| 666 | ArrayPrototypePush(batch, chunk); |
| 667 | } |
| 668 | if (batch.length > 0) { |
| 669 | yield batch; |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /** |
| 675 | * Fast path for validated stateful transforms (e.g. compression). |
no test coverage detected