ts-iterable-functions
    Preparing search index...

    Function cartesian

    • Computes the cartesian product of the provided sequences while preserving source order.

      Type Parameters

      • T

        Element type produced by each source iterable.

      Parameters

      • sequences: Iterable<Iterable<T, any, any>>

        Iterable of iterables for which to compute the cartesian product.

      Returns Iterable<Iterable<T, any, any>>

      A deferred iterable yielding every ordered combination of the source sequences.

      const combinations = [
      ...cartesian([
      ["A", "B"],
      [1, 2],
      ].map((arr) => arr.values())),
      ].map((combo) => [...combo]);
      console.log(combinations); // [["A", 1], ["A", 2], ["B", 1], ["B", 2]]