@extra-object/cartesian-product.min

Lists cartesian product of objects. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:] > Similar: [cartesianProduct], [zip]. > This is part of package [extra-object].

Usage no npm install needed!

<script type="module">
  import extraObjectCartesianProductMin from 'https://cdn.skypack.dev/@extra-object/cartesian-product.min';
</script>

README

Lists cartesian product of objects. :running: :vhs: :package: :moon: :ledger:

Similar: cartesianProduct, zip.
This is part of package extra-object.

This is browserified, minified version of @extra-object/cartesian-product.
It is exported as global variable object_cartesianProduct.
CDN: unpkg, jsDelivr.

object.cartesianProduct(xs, [fm]);
// xs: objects
// fm: map function (vs)
const object = require('extra-object');

var x = {a: 1, b: 2, c: 3};
var y = {d: 10, e: 20};
[...object.cartesianProduct([x, y])];
// [
//   { a: 1, d: 10 },
//   { a: 1, e: 20 },
//   { b: 2, d: 10 },
//   { b: 2, e: 20 },
//   { c: 3, d: 10 },
//   { c: 3, e: 20 }
// ]

[...object.cartesianProduct([x, y], a => object.max(a))];
// [
//   [ 'd', 10 ],
//   [ 'e', 20 ],
//   [ 'd', 10 ],
//   [ 'e', 20 ],
//   [ 'd', 10 ],
//   [ 'e', 20 ]
// ]

references