* Apply a fused run of stateless sync transforms. * @param {Iterable } source * @param {Array } run - Array of stateless transform functions * @yields {Uint8Array[]}
(source, run)
| 454 | * @yields {Uint8Array[]} |
| 455 | */ |
| 456 | function* applyFusedStatelessSyncTransforms(source, run) { |
| 457 | for (const chunks of source) { |
| 458 | let current = chunks; |
| 459 | for (let i = 0; i < run.length; i++) { |
| 460 | const result = run[i](current); |
| 461 | if (result === null) { |
| 462 | current = null; |
| 463 | break; |
| 464 | } |
| 465 | current = result; |
| 466 | } |
| 467 | if (current === null) continue; |
| 468 | // Inline normalization with Uint8Array[] batch as the fast path, |
| 469 | // matching the async pipeline's check order. |
| 470 | if (isUint8ArrayBatch(current)) { |
| 471 | if (current.length > 0) yield current; |
| 472 | } else if (isUint8Array(current)) { |
| 473 | yield [current]; |
| 474 | } else if (typeof current === 'string') { |
| 475 | yield [toUint8Array(current)]; |
| 476 | } else if (isAnyArrayBuffer(current)) { |
| 477 | yield [new Uint8Array(current)]; |
| 478 | } else if (ArrayBufferIsView(current)) { |
| 479 | yield [arrayBufferViewToUint8Array(current)]; |
| 480 | } else { |
| 481 | yield* processTransformResultSync(current); |
| 482 | } |
| 483 | } |
| 484 | // Flush each transform after all upstream data, including data emitted by |
| 485 | // earlier flushes, has been processed by that transform. |
| 486 | let pending = []; |
| 487 | for (let i = 0; i < run.length; i++) { |
| 488 | const next = []; |
| 489 | for (let j = 0; j < pending.length; j++) { |
| 490 | appendTransformResultSync(next, run[i](pending[j])); |
| 491 | } |
| 492 | appendTransformResultSync(next, run[i](null)); |
| 493 | pending = next; |
| 494 | } |
| 495 | for (let i = 0; i < pending.length; i++) { |
| 496 | yield pending[i]; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Apply a single stateful sync transform to a source. |
no test coverage detected
searching dependent graphs…