@mirei/ts-collections
    Preparing search index...

    Function cartesian

    • Produces the cartesian product between source and other.

      Type Parameters

      • TElement

        Type of elements in the source iterable.

      • TSecond

        Type of elements in the other iterable.

      Parameters

      • source: Iterable<TElement>

        The primary iterable that drives the resulting sequence.

      • other: Iterable<TSecond>

        The secondary iterable paired with every element from source.

      Returns IEnumerable<[TElement, TSecond]>

      A deferred sequence that yields each ordered pair [source, other].

      Re-throws any error raised while iterating source or other.

      The secondary iterable is fully buffered before iteration starts so that it can be replayed for every element from source. The resulting sequence stops when source completes.

      const pairs = cartesian([1, 2], ['A', 'B']).toArray();
      console.log(pairs); // [[1, 'A'], [1, 'B'], [2, 'A'], [2, 'B']]