1.0.0 • Published 6 years ago

ordered-cartesian-product v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Ordered Cartesian Product

Function that takes an ordering sequence and a mapping of dimensions and outputs the ordered cartesian product of combinations.

let combos = OrderedCartesianProduct(
  ["x", "y"],
  {
    "x": [1, 2, 3],
    "y": [4, 5, 6]
  }
)
console.log(combos);
/*
[
  {"x": 1, "y": 4},
  {"x": 1, "y": 5},
  {"x": 1, "y": 6},
  {"x": 2, "y": 4},
  {"x": 2, "y": 5},
  {"x": 2, "y": 6},
  {"x": 3, "y": 4},
  {"x": 3, "y": 5},
  {"x": 3, "y": 6}
]
*/