method Stream.zip
Stream.zip<
U,
F,
>
(other: Stream<U, F>): Stream<[T, U], E | F>

Combines this stream with another into tuples, yielding one result per pair of values. The shorter stream determines when zipping completes.

Examples

Example 1

import { Source } from "anabranch";

const stream1 = Source.from<number, never>(async function* () {
  yield 1;
  yield 2;
  yield 3;
});

const stream2 = Source.from<string, never>(async function* () {
  yield "a";
  yield "b";
});

const zipped = stream1.zip(stream2);
// Emits: { type: "success", value: [1, "a"] }, { type: "success", value: [2, "b"] }

Type Parameters

Parameters

other: Stream<U, F>

Return Type

Stream<[T, U], E | F>

Usage

import { type Stream } from ".";