UNPKG

cartesian-product-multiple-arrays

Version:

Find the cartesian product of multiple arrays.

30 lines (26 loc) 652 B
const { cartesianProductGenerator, } = require('cartesian-product-multiple-arrays'); const productAttributes = [ ['SM', 'MD', 'LG'], ['Red', 'Green'], ['Cotton', 'Polyester'], ]; const result = cartesianProductGenerator(...productAttributes); console.log(result.next().value); /* [ ['SM', 'Red', 'Cotton'], ['SM', 'Red', 'Polyester'], ['SM', 'Green', 'Cotton'], ['SM', 'Green', 'Polyester'], ['MD', 'Red', 'Cotton'], ['MD', 'Red', 'Polyester'], ['MD', 'Green', 'Cotton'], ['MD', 'Green', 'Polyester'], ['LG', 'Red', 'Cotton'], ['LG', 'Red', 'Polyester'], ['LG', 'Green', 'Cotton'], ['LG', 'Green', 'Polyester'], ] */