yta
    Preparing search index...

    Function zipLongest

    • Take any number of iterators, and zip them together into one iterator of tuples. It will continue yielding tuples until all the iterators have closed, putting undefined in the place of closed iterators.

      import { pipe } from "yta";
      import {
      flatRepeat,
      of,
      range,
      take,
      toArray,
      zipLongest,
      } from "yta/sync";

      pipe(
      zipLongest(
      of("a", "b"),
      range(5),
      pipe(
      flatRepeat(() => of(true, false)),
      take(3)
      ),
      ),
      toArray(),
      );
      // => [
      // ["a", 0, true],
      // ["b", 1, false],
      // [undefined, 2, true],
      // [undefined, 3, undefined],
      // [undefined, 4, undefined],
      // ]

      See also:

      Type Parameters

      • A extends unknown[]

        Tuple type with item type of each input iterator

      Parameters

      • ...items: { [K in string | number | symbol]: Iterable<A[K<K>], any, any> }

        The iterators to be zipped

      Returns Generator<{ [K in string | number | symbol]: A[K<K>] | undefined }, void, any>