augment-vir - v31.40.0
    Preparing search index...

    Function crossProduct

    • Creates the cartesian product (cross product) of an object whose values are arrays. The result is an array of objects where each object contains one picked value from every input array.

      Type Parameters

      • const OriginalValues extends Record<PropertyKey, readonly any[]>

      Parameters

      Returns { [Key in string | number | symbol]: ArrayElement<OriginalValues[Key]> }[]

      import {crossProduct} from '@augment-vir/common';

      const result = crossProduct({
      a: [
      1,
      2,
      3,
      ],
      b: [
      'a',
      'b',
      'c',
      ],
      });
      // result is:
      // [
      // {a: 1, b: 'a'}, {a: 2, b: 'a'}, {a: 3, b: 'a'},
      // {a: 1, b: 'b'}, {a: 2, b: 'b'}, {a: 3, b: 'b'},
      // {a: 1, b: 'c'}, {a: 2, b: 'c'}, {a: 3, b: 'c'},
      // ]