MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / pipeToSync

Function pipeToSync

src/pull.ts:610–658  ·  view source on GitHub ↗
(
  source: Iterable<Uint8Array[]>,
  ...args: (SyncTransform | SyncWriter | PipeToSyncOptions)[]
)

Source from the content-addressed store, hash-verified

608 // Yield results (filter out null from final output)
609 let completed = false;
610 try {
611 for await (const batch of abortableAsyncIterable(current, controller.signal)) {
612 if (batch !== null) {
613 yield batch;
614 }
615 }
616 completed = true;
617 } catch (error) {
618 if (!controller.signal.aborted) {
619 try {
620 controller.abort(error instanceof Error ? error : new Error(String(error)));
621 } catch { /* transform signal listeners may throw — suppress */ }
622 }
623 throw error;
624 } finally {
625 if (!completed && !controller.signal.aborted) {
626 try {
627 controller.abort(new DOMException('Aborted', 'AbortError'));
628 } catch { /* transform signal listeners may throw — suppress */ }
629 }
630 // Clean up user signal listener to prevent holding controller alive
631 if (signal && abortHandler) {
632 signal.removeEventListener('abort', abortHandler);
633 }
634 }
635}
636
637// =============================================================================
638// Public API: pull() and pullSync()
639// =============================================================================
640
641/**
642 * Create a sync pull-through pipeline with transforms.
643 *
644 * @param source - The sync streamable source
645 * @param args - Variadic transforms
646 * @returns A sync iterable yielding Uint8Array[] batches
647 */
648export function pullSync(
649 source: SyncStreamable,
650 ...transforms: SyncTransform[]
651): SyncByteStreamReadable {
652 return {
653 *[Symbol.iterator]() {
654 yield* createSyncPipeline(source, transforms);
655 },
656 };
657}
658
659/**
660 * Create an async pull-through pipeline with transforms.
661 *

Callers

nothing calls this directly

Calls 8

parsePipeToArgsFunction · 0.70
isTransformObjectFunction · 0.70
createSyncPipelineFunction · 0.70
pushMethod · 0.65
writevMethod · 0.65
writeMethod · 0.65
endMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected