yta
    Preparing search index...

    Function zip

    • Take any number of iterators, and zip them together into one iterator of tuples. Closes after the shortest of the inputs closes.

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

      pipe(
      zip(
      of("a", "b", "c"),
      range(),
      flatRepeat(() => of(true, false)),
      ),
      toArray(),
      );
      // => [["a", 0, true], ["b", 1, false], ["c", 2, true]]

      If you want to zip an iterator of iterators in a pipeline you can use them spread opperator.

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

      pipe(
      of(
      of("a", "b", "c"),
      range(),
      flatRepeat(() => of(true, false)),
      ),
      (iterables) => zip(...iterables),
      toArray(),
      );
      // => [["a", 0, true], ["b", 1, false], ["c", 2, true]]

      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<A, void, any>